functions - Auto Resize embedded videos player

admin2025-04-20  0

Hi I am importing videos through xml feed - But from one source, the video player is too wide and the sidebar ads overlap it. The code I found on the single.php is

<div class="video_player">  
<?php if(get_option('amn_videos') !=""){ 
        $video = get_post_meta($post->ID, get_option('amn_videos') ,true); if(!empty($video)) {
            echo resizeEmbedded($video); 
        }}else{
            echo remove_unwanted_tag__(resizeEmbedded(the_content()));

    }
    ?> 
</div>

In functions.php I found this //resizes embedded video html code to a specified width and height

function resizeEmbedded($subject) {
    $subject = preg_replace('/(width|height)(=|:)("|\'|)([\d]+)("|\'|)/', '${1}${2}${3}100%${3}', $subject);
    return $subject;
}

Now I don't know how to specify the width and height of the player, i tried tweaking 100% to 80% on the functions file but there is no effect. Is there a way to resize the videos through this code or use another code ? Any help would be highly appreciated.

Hi I am importing videos through xml feed - But from one source, the video player is too wide and the sidebar ads overlap it. The code I found on the single.php is

<div class="video_player">  
<?php if(get_option('amn_videos') !=""){ 
        $video = get_post_meta($post->ID, get_option('amn_videos') ,true); if(!empty($video)) {
            echo resizeEmbedded($video); 
        }}else{
            echo remove_unwanted_tag__(resizeEmbedded(the_content()));

    }
    ?> 
</div>

In functions.php I found this //resizes embedded video html code to a specified width and height

function resizeEmbedded($subject) {
    $subject = preg_replace('/(width|height)(=|:)("|\'|)([\d]+)("|\'|)/', '${1}${2}${3}100%${3}', $subject);
    return $subject;
}

Now I don't know how to specify the width and height of the player, i tried tweaking 100% to 80% on the functions file but there is no effect. Is there a way to resize the videos through this code or use another code ? Any help would be highly appreciated.

Share Improve this question asked Oct 1, 2019 at 17:32 Lost SouldLost Sould 33 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 0

You could set a max width to the container using CSS.

.video_player {
max-width: 800px;
overflow:hidden;
}
转载请注明原文地址:http://conceptsofalgorithm.com/Algorithm/1745114685a285794.html

最新回复(0)