Saad Shaikh
Saad Shaikh

Reputation: 83

I am unable to create thumbnail of video

I have an iframe on my website.I want to create a thumbnail of the video I have url of iframe stored in database.I want to create a thumbnail of the video I tried this code.

<img src="http://img.youtube.com/vi/_uQrJ0TkZlc/hqdefault.jpg" alt="" style="height:61px">

It's working perfectly but the problem is that the id which i used which is(_uQrJ0TkZlc)this it is static.I want that id should be dynamic which is there in my database table

This is my iframe

<iframe  style="width:10px;height:10px;" id="<?php echo $fetchorderdetails['id']?>" src="<?php echo $fetchorderdetails['video_links']?>rel=0&wmode=Opaque&enablejsapi=1;showinfo=0;" frameborder="0" allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>

Upvotes: 0

Views: 52

Answers (2)

digitalway
digitalway

Reputation: 71

You should use the "embed" version of the video url, with the embed word in it

<iframe width="200" height="150" src="https://www.youtube.com/embed/iqlp5g8-W3I" frameborder="0" allowfullscreen></iframe>

The non embeded url dont work in an iframe

Upvotes: 0

Jesse Schokker
Jesse Schokker

Reputation: 896

Instead of storing the entire link to the embedded video, only store the ID. This way you can both access the embedded video as well as the thumbnail link. To insert a variable in to a string use "<img src="http://img.youtube.com/vi/" . $id . "/hqdefault.jpg" alt="" style="height:61px">". See https://www.php.net/manual/en/language.operators.string.php

Upvotes: 3

Related Questions