I was wondering if it’s possible to use oEmbed that is built into the core of WP to display video embeds but somehow remove the height and width attritbutes in the output? I know the functions exist in media.php but I don’t want to mess with the core.
The reason I ask is that we’re developing a theme for a client which using a fluid grid framework and any image/video with specified height and width attributes means they don’t scale with the grid in smaller viewports – or there may be a way to make this work?
Any help would be much appreciated
Thanks
The output of the oEmbed call is filtered through
oembed_result
and then cached in the database. Every time the content is displayed, the output is filtered again throughembed_oembed_html
. So you can add a filter in either of these places that checks forwidth
andheight
attributes and removes them. Of course, since the code comes from the embed sources, you can’t always be sure what the formatting will look like. The second argument to both filters is the embed URL, you can check that to differentiate your handling (“if it’s from YouTube do this, if it’s from Flickr do that, …”).