WordPress.org

Make WordPress Core

Opened 6 years ago

Closed 6 years ago

#35240 closed defect (bug) (wontfix)

embed_oembed_html filter not used with wp_oembed_get

Reported by: theMikeD Owned by:
Milestone: Priority: normal
Severity: normal Version: 4.4
Component: Embeds Keywords:
Focuses: template Cc:

Description

There is a filter called embed_oembed_html that is useful for things like wrapping embedded videos to control dimensions via CSS. This filter is found in the code for executing shortcodes and works as expected when the url to be embedded exists in the post content. But it's not being called when the wp_oembed_get function is called.

To my way of thinking, it or a new filter be present in wp_oembed_get to enable the same kind of wrapping. Or is it supposed to be called and it's a bug? I'm not familiar with this section of the code so perhaps the issue lies elsewhere?

Change History (3)

#1 @swissspidy
6 years ago

  • Keywords close added

The embed_oembed_html filter is specific to the shortcode parsing because it's tightly coupled to the post the oEmbed is cached for. WP_Embed::shortcode itself calls wp_oembed_get().

wp_oembed_get() doesn't depend on any post, therefore we can't use the same filter there.

A new filter be present in wp_oembed_get to enable the same kind of wrapping

Since wp_oembed_get() calls \WP_oEmbed::get_html(), you can use its oembed_result filter to modify the response.

#2 @theMikeD
6 years ago

Ah, that did it. Thanks @swissspidy for the tip.

#3 @swissspidy
6 years ago

  • Keywords close removed
  • Milestone Awaiting Review deleted
  • Resolution set to wontfix
  • Status changed from new to closed
Note: See TracTickets for help on using tickets.