WordPress.org

Make WordPress Core

Opened 4 years ago

Last modified 3 years ago

#28619 new enhancement

Add more filters to tune audio and video shortcode library

Reported by: Fab1en Owned by:
Milestone: Future Release Priority: normal
Severity: normal Version: 3.9.1
Component: Media Keywords: needs-patch
Focuses: Cc:

Description

wp_video_shortcode_library and wp_audio_shortcode_library allow a plugin author to replace the default mediaelement.js library by another Audio/Video js library. But then, possibilities to modify the html rendering are very limited.

I have identified 2 points where a filter/action is needed :

  1. L1782 in wp-includes/media.php (https://github.com/WordPress/WordPress/blob/3.9.1/wp-includes/media.php#L1792)
$html = '';
if ( 'mediaelement' === $library && 1 === $instances )
	$html .= "<!--[if lt IE 9]><script>document.createElement('video');</script><![endif]-->\n";
  1. L1820 in wp-includes/media.php (https://github.com/WordPress/WordPress/blob/3.9.1/wp-includes/media.php#L1820)
if ( 'mediaelement' === $library )
	$html .= wp_mediaelement_fallback( $fileurl );

Plugin author should be able to add arbitrary HTML code before and inside the <video> tag as easily as this is done for mediaelement.

This could be done by replacing the previous lines with an filter call, and doing the mediaelement stuff inside the filter callback that can be unregistered and replaced by plugins.

Attachments (4)

28619.patch (3.9 KB) - added by Fab1en 4 years ago.
Add filters for audio and video shortcodes
28619.2.patch (5.6 KB) - added by Fab1en 4 years ago.
Add filters (with documentation) to tune mediaelement library
28619.3.patch (7.0 KB) - added by Fab1en 4 years ago.
28619.4.patch (7.2 KB) - added by Fab1en 4 years ago.

Download all attachments as: .zip

Change History (9)

@Fab1en
4 years ago

Add filters for audio and video shortcodes

#1 @nofearinc
4 years ago

New hooks need to be documented as per the Inline Documentation Standards.

@Fab1en
4 years ago

Add filters (with documentation) to tune mediaelement library

#2 follow-up: @Fab1en
4 years ago

OK, sorry. I thought we would discuss this a bit before adding docs. Inline docs added for filters in 28619.2.patch

#3 in reply to: ↑ 2 @DrewAPicture
4 years ago

Replying to Fab1en:

OK, sorry. I thought we would discuss this a bit before adding docs. Inline docs added for filters in 28619.2.patch

Hi @Fab1en, thanks for the patch. In many cases docs do get added at the end of the development cycle for new hooks, though in this case I think they really serve to help explain what's being proposed. :)

Your hook docs actually look pretty great. Probably the only things I would change would be the short descriptions. Our suggested language for filters is "Filter X" or "Filters X". So in this case, rather than using, "Adds HTML before the X", maybe it would be better as something like "Filter HTML prepended to the audio shortcode output." or similar. Make sense?

Also, if you pass the --no-prefix flag when generating your patches, it won't attach all of your personal information at the top of the patch :-).

@Fab1en
4 years ago

@Fab1en
4 years ago

#4 @Fab1en
4 years ago

OK, thanks for the explanation. The --no-prefix flag does not work on my git version (1.9.1) nor is it mentioned in the git-scm doc, so I removed the personal info manually.

28619.4.patch modifies the filters inline documentation. It also adds another filter to allow plugins author to support more external video providers (instead of just YouTube).

#5 @wonderboymusic
3 years ago

  • Keywords needs-patch added
  • Milestone changed from Awaiting Review to Future Release

The patch is currently exploding.

Note: See TracTickets for help on using tickets.