WordPress.org

Make WordPress Core

Opened 7 months ago

Last modified 7 months ago

#40144 new defect (bug)

Media: Unable to selectively opt for MediaElement.js for just audio or video shortcodes

Reported by: westonruter Owned by:
Milestone: Awaiting Review Priority: normal
Severity: normal Version: 3.6
Component: Media Keywords: has-patch
Focuses: Cc:

Description

Let's say someone adds a plugin that does the following:

  • add_filter( 'wp_video_shortcode_library', function(){ return 'some_other_library'; } );
  • add_filter( 'wp_audio_shortcode_library', function(){ return 'some_other_library'; } );

If both of the filters are added, then wp-mediaelement won't be enqueued. However, if only one of the filters are added, then wp-mediaelement will still get enqueued. When wp-mediaelement is enqueued, it uses this selector to find the elements to initialize with MediaElement.js:

$( '.wp-audio-shortcode, .wp-video-shortcode' )

Naturally this means that even if I have filtered wp_video_shortcode_library to not be mediaelement, the JS will still try to set it up for MediaElement.js if I didn't also filter wp_audio_shortcode_library to not be mediaelement.

The JS needs to be aware of what the wp_video_shortcode_library and wp_audio_shortcode_library filters so that it can know whether or not to include .wp-audio-shortcode and .wp-video-shortcode among the selectors.

Originally raised in https://github.com/xwp/wp-core-media-widgets/pull/5#issuecomment-285198669

Attachments (1)

40144.0.diff (2.0 KB) - added by westonruter 7 months ago.

Download all attachments as: .zip

Change History (3)

@westonruter
7 months ago

#1 @westonruter
7 months ago

  • Keywords has-patch added
  • Version set to 3.6

This ticket was mentioned in Slack in #core-customize by westonruter. View the logs.


7 months ago

Note: See TracTickets for help on using tickets.