Make WordPress Core

Opened 2 years ago

Closed 2 years ago

#24070 closed defect (bug) (fixed)

[embed] from structured video/audio post format not working with post_formats_compat.

Reported by: jbobich Owned by: markjaquith
Milestone: 3.6 Priority: normal
Severity: normal Version: 3.6
Component: Post Formats Keywords: has-patch
Focuses: Cc:


When using a theme that relies on post_formats_compat for video and audio posts (Twenty Twelve currently for example) --

If the user puts a video/audio file URL in through the new post formats UI with not video in the content of the page, the media will not embed properly within the final output of the_content().

Attachments (4)

24070.diff (524 bytes) - added by jbobich 2 years ago.
Screen Shot 2013-04-12 at 2.41.37 PM.png (140.2 KB) - added by jbobich 2 years ago.
24070.2.diff (2.5 KB) - added by kovshenin 2 years ago.
24070.3.diff (2.1 KB) - added by kovshenin 2 years ago.

Download all attachments as: .zip

Change History (13)

@jbobich2 years ago

comment:1 @jbobich2 years ago

Apologies, what I meant to say was --

"If the user puts a video/audio file URL in through the new post formats UI with no embed in the content of the page, the media will not embed properly within the final output of the_content()."

comment:2 @wonderboymusic2 years ago

The video does not display?

comment:3 @jbobich2 years ago

Yup. I'm using latest trunk version with TwentyTwelve with no plugins installed. Can you not reproduce?

For example, I have a post setup like this:


Before my patch, it displays like this:


After, it displays as you'd expect:


comment:4 @wonderboymusic2 years ago

  • Milestone changed from Awaiting Review to 3.6

I see it now, that is really bizarre

@kovshenin2 years ago

comment:5 @kovshenin2 years ago

This is interesting, and not limited to post formats, but the [embed] shortcode with audio and video files. The problem lies within the WP_Embed->shortcode method, which calls the wp_audio_embed and wp_video_embed functions, both of which return the URL, and not the embedded media, because WP_Embed->shortcode runs when all other shortcodes are not registered yet.

The reason it "works" is that the resulting URL is picked up by WP_Embed->autoembed and parsed again using wp_audio_embed or wp_video_embed, so if there's anything else on the same line that doesn't match the audio/video regexes, it fails. Even worse is when the resulting URL contains a </div> like in the content produced by the audio/video formats compat code. This breaks the theme's markup because both embed handlers don't escape the URL.

24070.2.diff makes both embed handlers return the (undone) shortcode, regardless of whether the shortcode has been registered or not.

comment:6 follow-up: @jbobich2 years ago

@kovshenin -- Awesome, that definitely solves it.

Is there a reason why wp_audio_embed and wp_video_embed need to parse the shorcodes to begin with (i.e. before 24070.2.diff)? Meaning, does removing that functionality and just allowing the shortcodes to be parsed along with everything else later on effect anything else?

Version 1, edited 2 years ago by jbobich (previous) (next) (diff)

comment:7 in reply to: ↑ 6 @kovshenin2 years ago

Replying to jbobich: The functions don't do any shortcode parsing, they're callbacks for WP_Embed, meaning you can insert a URL to an .mp3 file on a line by itself, and WordPress will figure it out and embed it in an audio player, sort of how you can insert links to YouTube videos or tweets (though that's a tiny bit different).

@kovshenin2 years ago

comment:8 @kovshenin2 years ago

Refreshed in 24070.3.diff after [24000].

comment:9 @markjaquith2 years ago

  • Owner set to markjaquith
  • Resolution set to fixed
  • Status changed from new to closed

In 24083:

Fix issue with [embed] in post_format_compat.

props kovshenin. fixes #24070.

Note: See TracTickets for help on using tickets.