• Resolved enricobt

    (@enricobt)


    Hello
    I have a PHP program that inserts youtube videos into a post by taking the youtube ID assigned from a data field
    The code was as follows
    <?php if ( $ytID ) { ?>
    <div> Video from our YOUTUBE channel
    </div>
    <iframe width=”100%” height=”450″ src=”https://www.youtube.com/embed/&lt;?php echo $ytID ?>”></iframe>
    <?php } ?>

    But after some AMP plugin updates, I can’t tell exactly when, this code no longer worked and I had to add a new amp component, so that code is now like this.

    <?php if ( $ytID ) { ?>
    <div> Video from our YOUTUBE channel
    </div>
    <iframe width=”100%” height=”450″ src=”https://www.youtube.com/embed/&lt;?php echo $ytID ?>”></iframe>
    <amp-youtube width=”480″ height=”270″ layout=”responsive” data-videoid=”<?php echo $ytID ?>”></amp-youtube>
    <?php } ?>

    It works fine, but I would like to make sure this is a good solution or if there is a better one.

    Thanks
    Enrico

    The page I need help with: [log in to see the link]

Viewing 6 replies - 1 through 6 (of 6 total)
  • Plugin Support Milind More

    (@milindmore22)

    Hello @enricobt

    Thank you for the support topic, The width="100%" is an invalid attribute, you need to replace it with a value like width="560" or just remove the attribute.

    eg: width value

    <iframe height="450" width="560"src="https://www.youtube.com/embed/s52JNMT59s8"></iframe>

    OR no width

    <iframe height="450" src="https://www.youtube.com/embed/s52JNMT59s8"></iframe>

    Hope this helps!

    Thread Starter enricobt

    (@enricobt)

    Hi (@milindmore22)
    Thanks for your help!
    I used this code then
    <iframe width=”560″ height=”315″ src=”https://www.youtube.com/embed/s52JNMT59s8″></iframe&gt;
    and it works fine on desktop.

    Do I need to make it responsive in some way?

    What about AMP component? is it still needed?
    <amp-youtube width=”480″ height=”270″ layout=”responsive” data-videoid=”s52JNMT59s8”></amp-youtube>

    Regards

    Plugin Support Milind More

    (@milindmore22)

    Hello @enricobt

    Glad to know, No you don’t need to add anything different to make it responsive on desktop

    and No you don’t need to <amp-youtube> as the AMP plugin will convert <iframe> tag into <amp-youtube>

    Thread Starter enricobt

    (@enricobt)

    Many thanks, Milind! that’s good news!

    Plugin Support Milind More

    (@milindmore22)

    Glad our suggestion is helpful, I’ll mark this as resolved Open a new support topic if you face further issues, also feel free to leave a plugin review, we would love to hear your feedback.

    Plugin Author Weston Ruter

    (@westonruter)

    @milindmore22 When the AMP plugin encounters an element with width=100% it should be converting the element to layout=fixed-height. So it shouldn’t have been needed to provide a specific height.

    It’s supposed to be that given this input:

    <iframe width="100%" height="315" src=”https://www.youtube.com/embed/s52JNMT59s8″></iframe>

    It should result in:

    <amp-youtube layout="fixed-height" height="315" src=”https://www.youtube.com/embed/s52JNMT59s8″></amp-youtube>

    If this isn’t the case, then this would be a big. Could you double check?

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Youtube Video’ is closed to new replies.