• Skip to main content
  • Skip to forum navigation

StudioPress

  • Shop for Themes
  • My StudioPress

Forum navigation

  • Home
  • General Genesis Discussions
  • StudioPress Themes
  • Genesis Blocks
    • Genesis Blocks
    • Genesis Custom Blocks
  • Retired Themes
  • FAQs
  • Forum Rules
  • Internationalization and Translations
  • Forum Bugs and Suggestions
  • Forum Log In

Are You Using The WordPress Block Editor?

Genesis now offers plugins that help you build better sites faster with the WordPress block editor (Gutenberg). Try the feature-rich free versions of each plugin for yourself!

Genesis Blocks Genesis Custom Blocks

How to Make Embedded YouTube Videos Responsive on Genesis?

Welcome!

These forums are for general discussion on WordPress and Genesis. Official support for StudioPress themes is offered exclusively at My StudioPress. Responses in this forum are not guaranteed. Please note that this forum will require a new username, separate from the one used for My.StudioPress.

Log In
Register Lost Password

Community Forums › Forums › Archived Forums › General Discussion › How to Make Embedded YouTube Videos Responsive on Genesis?

This topic is: not resolved

Tagged: embed youtube, responsive

  • This topic has 2 replies, 2 voices, and was last updated 9 years, 1 month ago by dedsonus.
Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • December 23, 2016 at 12:52 am #198030
    dedsonus
    Member

    Hello,
    i'd like to add a div around embed youtube codes by default to make all videos responsive. I have hundreds of videos on my blog so i'd like to make it using functions.php not by manually adding code to each video.

    What i want to do:

    <div class="video-container">
            <iframe src="https://www.youtube.com/embed/rFyfFHXsofk" width="800" height="450" frameborder="0" allowfullscreen="allowfullscreen"></iframe>
    </div>

    I'm using this CSS code:

    .video-container { position: relative; padding-bottom: 56.25%; height: 0; overflow: hidden; }
    .video-container iframe, .video-container object, .video-container embed, .video-container video { position: absolute; top: 0; left: 0; width: 100%; height: 100%; }

    I've tried two different codes in functions.php but none of them seem to be working.

    Here is the first one:

    /*  Add responsive container to embeds
    /* ------------------------------------ */ 
    function alx_embed_html( $html ) {
        return '<div class="video-container">' . $html . '</div>';
    }
     
    add_filter( 'embed_oembed_html', 'alx_embed_html', 10, 3 );
    add_filter( 'video_embed_html', 'alx_embed_html' ); // Jetpack

    Here is the second:

    add_filter( 'embed_oembed_html', 'custom_oembed_filter', 10, 4 ) ;
    
    function custom_oembed_filter($html, $url, $attr, $post_ID) {
        $return = '<div class="video-container">'.$html.'</div>';
        return $return;
    }

    I'm using Eleven40 Pro theme.
    Is there any way to make it working? Thank you.

    December 23, 2016 at 7:56 am #198039
    Victor Font
    Moderator

    The problem is that you are using iframes. Resizing iframes is difficult to say the least. This might provide some insight into resizing iframes with CSS: https://benmarshall.me/responsive-iframes/


    Regards,

    Victor
    https://victorfont.com/
    Call us toll free: 844-VIC-FONT (842-3668)
    Have you requested your free website audit yet?

    December 23, 2016 at 8:18 am #198043
    dedsonus
    Member

    Thank you, Victor!
    I'll try this solution.
    Regards,
    Mike

  • Author
    Posts
Viewing 3 posts - 1 through 3 (of 3 total)
  • The forum ‘General Discussion’ is closed to new topics and replies.

CTA

Ready to get started? Create a site or shop for themes.

Create a site with WP EngineShop for Themes

Footer

StudioPress

© 2026 WPEngine, Inc.

Products
  • Create a Site with WP Engine
  • Shop for Themes
  • Theme Features
  • Get Started
  • Showcase
Company
  • Brand Assets
  • Terms of Service
  • Accptable Usse Policy
  • Privacy Policy
  • Refund Policy
  • Contact Us
Community
  • Find Developers
  • Forums
  • Facebook Group
  • #GenesisWP
  • Showcase
Resources
  • StudioPress Blog
  • Help & Documentation
  • FAQs
  • Code Snippets
  • Affiliates
Connect
  • StudioPress Live
  • StudioPress FM
  • Facebook
  • Twitter
  • Dribbble