开发者 | sutherlandboswell |
---|---|
更新时间 | 2016年8月28日 01:09 |
捐献地址: | 去捐款 |
PHP版本: | 3.2 及以上 |
WordPress版本: | 4.5 |
/video-thumbnails/
directory to the /wp-content/plugins/
directory<?php video_thumbnail(); ?>
will echo a thumbnail URL or the default image located at wp-content/plugins/video-thumbnails/default.jpg
if a thumbnail cannot be found. Here is an example: <img src="<?php video_thumbnail(); ?>" width="300" />
<?php $video_thumbnail = get_video_thumbnail(); ?>
will return the thumbnail URL or return NULL if none is found. In this example, a thumbnail is only shown if one is found: <?php if( ( $video_thumbnail = get_video_thumbnail() ) != null ) { echo "<img src='" . $video_thumbnail . "' />"; } ?>
Video Thumbnails uses high-resolution widescreen thumbnails whenever they are available. If a video is not in HD, a fullscreen thumbnail is used. This can result in letterboxing when the video is actually widescreen. Users of the pro version can select an aspect ratio in the settings if this is a constant problem. More info.
No, Video Thumbnails only uses thumbnails provided by the source. If you're posting videos from your own account, many providers allow you to choose the thumbnail.
No, it will only fetch thumbnails for videos from the list of supported sites. Decoding local video files to create thumbnails would require server resources and packages unavailable to most users, so we only focus on supporting major video sites.
The most likely problem is that your theme doesn't support post thumbnails. If thumbnails are supported, you should see a box titled "Featured Image" on the edit post page. If thumbnails aren't supported, your theme will have to be modified to support Featured Images or to support one of our custom functions.
On the Video Thumbnails settings page just enter the name of the custom field and the plugin will scan it.
Yes, but be sure to include the post ID as a parameter. For example: <?php $thumbnail = get_video_thumbnail(25); ?>
If the service allows a way to retrieve thumbnails, I'll do my best to add it.
The settings page includes a checklist of all your post types so you can pick and choose.
<?php if( ( $video_thumbnail = get_video_thumbnail() ) != null ) { echo "<img src='" . $video_thumbnail . "' />"; } ?>
will only display a thumbnail when one exists, but I recommend using the Featured Image setting and the_post_thumbnail template tag.
The best solution is to use the Featured Image setting and the_post_thumbnail template tag. As an alternative you could assign a class to the element and style it with CSS.
Every theme is different, so this can be tricky if you aren't familiar with WordPress theme development. You need to edit your template in the appropriate place, replacing <?php the_content(); >
with <?php the_excerpt(); >
so that only an excerpt of the post is shown on the home page or wherever you would like to display the video thumbnail.
The Vimeo API has a rate limit, so in rare cases you may exceed this limit. Try again after a few hours.
video_thumbnail()
or get_video_thumbnail()
function. For example: <?php $id = 25; $thumbnail = get_video_thumbnail($id); if($thumbnail!=null) echo $thumbnail; ?>
video_thumbnail()
or get_video_thumbnail()
is called in a loop for that post.get_video_thumbnail()
to return the URL without echoing or return null if no thumbnail is found, making it possible to only display a thumbnail if one is found.