How to display video as thumbnail image in magento [duplicate]
-
06-10-2020 - |
Question
How to display YouTube video as thumbnail image in Magento?
Solution
$videourl
is youtube video url and in phtml file you can put this.
Try below code:
<?php
$posOfV = strpos($videourl,'?v=');
if($posOfV === false)
{
$explodeArr = explode("youtu.be/",$videourl);
$embedId = $explodeArr[1];
}
else
{
$explodeArr = explode("?v=",$videourl);
$pos = strpos($explodeArr,'&');
if($pos === false)
{
$embedId = $explodeArr[1];
}
else
{
$explodedAgain = explode("&",$explodeArr[1]);
$embedId = $explodedAgain[0];
}
}
?>
<div>
<iframe width="300" height="160" src="http://www.youtube.com/embed/<?php echo $embedId ?>" frameborder="0" allowfullscreen></iframe>
</div>
Licensed under: CC-BY-SA with attribution
Not affiliated with magento.stackexchange