• Resolved rossagrant

    (@rossagrant)


    Oembed settings for max height/ width etc used to be under the settings—>media tab.

    This now only seems to reference images and not video embeds etc.

    Anyone know where this can be set?

    It’s super important as otherwise oembeds just spill over the body of the theme.

    Please can someone let me know!

    Thanks ??

Viewing 13 replies - 1 through 13 (of 13 total)
  • Same issue after upgrading to 3.5. Release notes say it should default to content width, but it’s not so for androidpolice.com. I upgraded a test install, and embeds are left aligned and occupy about 2/3 of the post width.

    Gotta love removing all related settings, as per notes, but not specifying a way to tweak it if it doesn’t work right. Time to go dig through the code.

    Thread Starter rossagrant

    (@rossagrant)

    I’m using Buddypress and the youtube oembeds just appear huge and spill right over the body of the activity stream pages and forums.

    Funnily enough, existing oembeds are fine, they seem to retain the max width set in the previous version.

    This seems to be a pretty big oversight that needs fixing fast IMO.

    Let me know how you get on.

    @rossagrant Existing oembeds are cached in WordPress and will therefore use the cached embed tags. If you clear out the cached values, they’ll get re-requested and will then grow out of control as per current settings.

    Thread Starter rossagrant

    (@rossagrant)

    Ahh okay, well this needs fixing ASAP then!

    Can’t believe they took away this functionality!

    Moderator Samuel Wood (Otto)

    (@otto42)

    www.remarpro.com Admin

    What is the content_width set to by your theme? If there is no global $content_width set by the theme (or anything else, really), then it defaults to 500 pixels wide.

    Moderator Samuel Wood (Otto)

    (@otto42)

    www.remarpro.com Admin

    Note that this is easy to change, and any modern theme should have it set properly for that theme already.

    In the theme’s functions.php, there should be something like this:

    global $content_width;
    $content_width = 500;

    Or whatever the width of the main content area is.

    That did it, Otto.

    I am willing to bet that many people don’t have an up-to-date theme or a theme was created in-house without this option (first time I’ve heard of it myself for example).

    Either way, thanks for the help.

    Moderator Samuel Wood (Otto)

    (@otto42)

    www.remarpro.com Admin

    Note that the content width affects *loads* of things, so it is important that you set it to the actual width of the “content area” of your theme, not just to how wide you want oembeds to be. Content width also determines the maximum size of embedded images, for example.

    Also, our Theme Check plugin will warn you about issues like this with themes. We use this here on www.remarpro.com for helping theme authors clean up their themes before submitting to the theme repository. Might be worth giving it a run over your theme too. ??

    Thread Starter rossagrant

    (@rossagrant)

    So what if I don’t want oembeds the full width Sam?

    Is there any specific function just for the oembeds?

    Not quite sure why the old settings had to go. They were great and super flexible for everyone?

    Moderator Samuel Wood (Otto)

    (@otto42)

    www.remarpro.com Admin

    Almost nobody used them, actually, and there wasn’t a good reason to have them. They defaulted to the content width, and adjusting them individually like that didn’t make a lot of sense.

    Furthermore, it was argued that this should really be a function of the theme. Users generally want things to look right to start out with, not to micromanage the layout. The theme should define the widths and things.

    If you absolutely, positively, must custom set this value to something else, here’s some code you can put in the theme’s functions.php file.

    add_filter('embed_defaults','themename_embed_defaults');
    function themename_embed_defaults($defaults) {
       $defaults['width']=123;
       $defaults['height']=123;
       return $defaults;
    }

    This is what themes should use if they need to set special case default sizes for oembed’d content. Note that both width and height are considered “max” sizes, the actual content returned from the provider will be whatever the provider wants to return. No guarantees on exact sizing.

    Thread Starter rossagrant

    (@rossagrant)

    Cheers Otto,

    I’m just not sure exactly how my theme works, it’s a new kind of framework that is still kind of in beta, so if I can manage this stuff manually for now then that might be best.

    I’ll try that function, thanks for your help!

    this thread was very helpful. i had what i thought was a great theme by graphpaperpress but i guess it overlooked this detail.

    this is an issue – kinda breaks the backward compatibility of wordpress in a small way.

    the fix was easy however.

    This was exactly what I needed. Thanks!

Viewing 13 replies - 1 through 13 (of 13 total)
  • The topic ‘How to set max width of oembeds in WP 3.5?’ is closed to new replies.