• Hi,

    Is there a way to set the width of wordpresses video auto-embed for an entire wordpress installation/website, so I don’t have to wrap the shortcode for every separate youtube or vimeo embed or change each post separately when changing themes? Perhaps some filter or snippet I can put in functions.php or a setting in wp-config?

    I would like to know and haven’t found this, just the shortcode in the codex. I don’t want to set size on a video by video basis and am wondering if there is something possible on a global level.

    Anyone?

    Thanks,
    Hans

Viewing 2 replies - 1 through 2 (of 2 total)
  • Moderator Steven Stern (sterndata)

    (@sterndata)

    Volunteer Forum Moderator

    This should work for you. Put in in a plugin or drop it in your theme’s functions.php:

    add_filter( 'embed_defaults', 'change_embed_size' );
    
    function change_embed_size() {
        // Adjust values
        return array('width' => 100, 'height' => 100);
    }

    Lots of other embed filters are available. see https://hookr.io/all/#index=e

    Thread Starter Hans Schuijff

    (@hanswitteprins)

    Hi Steve,

    Great tip, thanks! Just wat I wanted.

    I’ve tried it out, but found that only the value of height is set to the entered value and the width is varied so the proportions are maintained. I would, off course, like it the other way around, since I want the width to fill 100% of the available content-space, like the other content. I will keep digging, but if you have any additional tips I would appreciate them.

    Looking at wp_embed_defaults() in media.php I would think the height would be varied to accommodate correct proportions, so I don’t yet know why in my case it seems to be done the other way around.

    To be exclude conflicts with other logic, I already tried prefixing the function and set the priority to a high number to have the custom filter run last.

    If I find anything noteworthy, I will post it here again. Thanks so far.

    Kind regards,

    Hans

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘How to set the width of video auto-embed?’ is closed to new replies.