mercredi 1 juillet 2015

I am writing a script to embed Youtube or vimeo videos into magento product page

Youtube embed code has letters and vimeo embed code has numbers example v?cVxmbd5 and Vimeo is like Vimeo.com/6847539 . I am writing a script to pull the end of embed strings with letters to match it with top iframe and pull end of embed strings with no letters to match with bottom iframe.

This script is supposed to embed videos into a video tab on the product view page.

When I run code, the entire video tab disappears. Any suggestions?

<?php $_product = $this->getProduct(); ?>
<?php
if ($_product->getVideo()):
$videos = explode(', ', $_product->getVideo());
foreach ($videos as $video):
    if(ctype_alpha($video)):
    ?>




    <iframe width='560' height='315' style='max-width:100%;' src='http://www.youtube.com/embed/<?php echo $video ?>' frameborder='0' allowfullscreen></iframe> 

    <?php else: ?>    

    <iframe width="560" height="315" style="max-width:100%;" src="https://player.vimeo.com/video/<?php echo $video ?>" frameborder="0" allowfullscreen></iframe>


    <?php
    endif;
 endforeach;
endif;

?>

Aucun commentaire:

Enregistrer un commentaire