我的网站上有一个 iframe
。我想创建视频的缩略图
我在数据库中存储了 iframe
的 url
。我想创建视频的缩略图
我尝试了这段代码。
<img src="http://img.youtube.com/vi/_uQrJ0TkZlc/hqdefault.jpg" alt="" style="height:61px">
它工作得很好,但问题是我使用的 id 是(_uQrJ0TkZlc)
它是静态的。我希望该 id 应该是动态的,它存在于我的数据库表中
这是我的 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>
最佳答案
不存储嵌入视频的整个链接,只存储 ID。这样您就可以访问嵌入的视频以及缩略图链接。要将变量插入到字符串中,请使用 "<img src="http://img.youtube.com/vi/" . $id . "/hqdefault.jpg" alt="" style="height:61px">"
。请参阅https://www.php.net/manual/en/language.operators.string.php
关于javascript - 我无法创建视频缩略图,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57901495/