Viewing 1 replies (of 1 total)
  • Thread Starter bward

    (@bward)

    I resolved this a while back by adding this to my functions file. Hopefully, it will help someone in the future. Seems to cover everything we needed.

    // Add Responsive To Embeds With CSS Class "video-container"
    function div_wrapper_video_container($content) {
        // match any iframes
        $pattern = '~<iframe.*</iframe>|<embed.*</embed>~';
        preg_match_all($pattern, $content, $matches);
    
        foreach ($matches[0] as $match) {
            // wrap matched iframe with div
            $wrappedframe = '<div class="video-container">' . $match . '</div>';
    
            //replace original iframe with new in content
            $content = str_replace($match, $wrappedframe, $content);
        }
    
        return $content;    
    }
    add_filter('the_content', 'div_wrapper_video_container');
Viewing 1 replies (of 1 total)
  • The topic ‘Video Not Responsive Except On “Page”’ is closed to new replies.