Make WordPress Core

Opened 12 years ago

Closed 12 years ago

#24070 closed defect (bug) (fixed)

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

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

Description

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 12 years ago.
Screen Shot 2013-04-12 at 2.41.37 PM.png (140.2 KB) - added by jbobich 12 years ago.
24070.2.diff (2.5 KB) - added by kovshenin 12 years ago.
24070.3.diff (2.1 KB) - added by kovshenin 12 years ago.

Download all attachments as: .zip

Change History (13)

@jbobich
12 years ago

#1 @jbobich
12 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()."

#2 @wonderboymusic
12 years ago

The video does not display?

#3 @jbobich
12 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:

http://www.uploadblvd.com/uploads/image_5168921c85b8c.png

Before my patch, it displays like this:

http://www.uploadblvd.com/uploads/image_516891bd6f206.png

After, it displays as you'd expect:

http://www.uploadblvd.com/uploads/image_5168920ea737d.png

#4 @wonderboymusic
12 years ago

  • Milestone changed from Awaiting Review to 3.6

I see it now, that is really bizarre

@kovshenin
12 years ago

#5 @kovshenin
12 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.

#6 follow-up: @jbobich
12 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?

Last edited 12 years ago by jbobich (previous) (diff)

#7 in reply to: ↑ 6 @kovshenin
12 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).

@kovshenin
12 years ago

#8 @kovshenin
12 years ago

Refreshed in 24070.3.diff after [24000].

#9 @markjaquith
12 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.