#40144 closed defect (bug) (fixed)
Media: Unable to selectively opt for MediaElement.js for just audio or video shortcodes
Reported by: | westonruter | Owned by: | joedolson |
---|---|---|---|
Milestone: | 6.2 | Priority: | normal |
Severity: | normal | Version: | 3.6 |
Component: | Media | Keywords: | has-patch commit |
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 (4)
Change History (16)
This ticket was mentioned in Slack in #core-customize by westonruter. View the logs.
8 years ago
This ticket was mentioned in Slack in #core-media by joedolson. View the logs.
2 years ago
#4
@
2 years ago
- Milestone changed from Awaiting Review to 6.2
- Owner set to joedolson
- Status changed from new to accepted
#5
@
2 years ago
Testing instructions:
- Create a post in the classic editor
- Add an audio file and a video file using the [audio] and [video] shortcodes.
- Add the two filters
add_filter( 'wp_video_shortcode_library', function(){ return 'some_other_library'; } ); add_filter( 'wp_audio_shortcode_library', function(){ return 'some_other_library'; } );
Test once with both filters available; once with only one filter enabled; one with the other filter enabled.
Before patch:
- Both filters: both audio and video fall back to native players.
- Audio filter: both audio and video fall back to native players.
- Video filter: both audio and video fall back to native players.
After patch:
- Both filters: both audio and video fall back to native players.
- Audio filter: Audio player falls back to native player.
- Video filter: Video player falls back to native player.
This ticket was mentioned in Slack in #core-media by joedolson. View the logs.
23 months ago
#8
@
22 months ago
I have tested with the refreshed patch: https://core.trac.wordpress.org/attachment/ticket/40144/40144.3.diff
I have created a post in the classic editor and:
Added an audio file and a video file using the [audio] and [video] shortcodes.
Added these two filters in themes function.php file:
add_filter( 'wp_video_shortcode_library', function(){ return 'some_other_library'; } ); add_filter( 'wp_audio_shortcode_library', function(){ return 'some_other_library'; } );
Tested once with both filters available; once with only one filter enabled; one with the other filter enabled.
Before patch:
Both filters: Both audio and video fall back to native players - https://d.pr/i/k7OONM
Audio filter: Both audio and video fall back to native players - https://d.pr/i/Rm8NHI
Video filter: Both audio and video fall back to native players - https://d.pr/i/d75r7x
After patch:
Both filters: Both audio and video fall back to native players - https://d.pr/i/9BQuh4
Audio filter: Audio player falls back to native player - https://d.pr/i/IOshs4
Video filter: Video player falls back to native player - https://d.pr/i/eoybpX
After Patch I have found the expected result.
This ticket was mentioned in PR #4025 on WordPress/wordpress-develop by @joedolson.
22 months ago
#10
Allow filters to disable mediaelement shortcodes selectively
Trac ticket: https://core.trac.wordpress.org/ticket/40144
Milestoning for 6.2 after scrubbing. This makes a lot of sense.