最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

post thumbnails - Use Video as Featured Image

programmeradmin3浏览0评论

I have been looking for a non plugin solution where a user can upload a video, say, something from a site like /.

When the user adds the video via the featured image link in the post/page editor, a static image will be generated and used as the featured image, but when the post is viewed, the title of the post is displayed on top of the actual video being played.

Hope that made sense. So far I haven't found anything. Ideas?

I have been looking for a non plugin solution where a user can upload a video, say, something from a site like http://www.coverr.co/.

When the user adds the video via the featured image link in the post/page editor, a static image will be generated and used as the featured image, but when the post is viewed, the title of the post is displayed on top of the actual video being played.

Hope that made sense. So far I haven't found anything. Ideas?

Share Improve this question asked Dec 6, 2016 at 19:00 tsqueztsquez 851 silver badge9 bronze badges 5
  • You said site like ... what other sites? – prosti Commented Dec 6, 2016 at 22:20
  • I can clearly see the link, but here it is again [coverr.co] (coverr.co) a site like that. – tsquez Commented Dec 7, 2016 at 13:23
  • No, it was not the problem with the URL, but I thought there are other distinct sites like this one from where you are doing things... – prosti Commented Dec 7, 2016 at 13:25
  • The biggest problem with this is that you're asking WordPress to take a picture of the first frame of whatever video it's pulling. Sites like youtube already have these images set where you can pull them from video ID like this and set them in WordPress like this. This is probably too hefty for a simple code snippet and better suited as a Plugin. An answer may not be feasible and the question ends up as too broad. – Howdy_McGee Commented Jan 5, 2017 at 23:54
  • @Howdy_McGee An answer is always feasible amigo, some how, some way. The question still remains simple: When the user adds the video via the featured image link in the post/page editor, a static image will be generated and used as the featured image, but when the post is viewed, the title of the post is displayed on top of the actual video being played. Thanks for the info though, its greatly appreciated – tsquez Commented Jan 6, 2017 at 19:06
Add a comment  | 

1 Answer 1

Reset to default 1

You can work around if you have time.
- Install http://ffmpeg-php.sourceforge/
- Create a custom meta field (upload field - you can use a plugin)
- In your template or loop, get retrieve the uploaded video URL and assign it to a variable
- Use the following function to generate an image from the retrieved video (I am not entirely sure if it will work and if it will not slow down your website)

$frame = 10;
$movie = 'test.mp4';   // this could be the variable from the vid url
$thumbnail = 'thumbnail.png';

$mov = new ffmpeg_movie($movie);  
$frame = $mov->getFrame($frame);
if ($frame) {
    $gd_image = $frame->toGDImage();
    if ($gd_image) {
       imagepng($gd_image, $thumbnail);
       imagedestroy($gd_image);
       echo '<img src="'.$thumbnail.'">';
    }
}

Original question: https://stackoverflow/questions/2043007/generate-preview-image-from-video-file

发布评论

评论列表(0)

  1. 暂无评论