Media: Introduce a custom error handler for MediaElement.js to display a download link if a FLV file cannot be rendered for any reason.
Props Clorith. Fixes #42643. git-svn-id: https://develop.svn.wordpress.org/trunk@42582 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
818a0f1ccf
commit
1a748ed226
@ -1,4 +1,4 @@
|
||||
/* global _wpmejsSettings */
|
||||
/* global _wpmejsSettings, mejsL10n */
|
||||
(function( window, $ ) {
|
||||
|
||||
window.wp = window.wp || {};
|
||||
@ -44,6 +44,25 @@
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Custom error handler.
|
||||
*
|
||||
* Sets up a custom error handler in case a video render fails, and provides a download
|
||||
* link as the fallback.
|
||||
*
|
||||
* @since 4.9.3
|
||||
*
|
||||
* @param {object} media The wrapper that mimics all the native events/properties/methods for all renderers.
|
||||
* @param {object} node The original HTML video, audio, or iframe tag where the media was loaded.
|
||||
* @returns {string}
|
||||
*/
|
||||
settings.customError = function ( media, node ) {
|
||||
// Make sure we only fall back to a download link for flash files.
|
||||
if ( -1 !== media.rendererName.indexOf( 'flash' ) || -1 !== media.rendererName.indexOf( 'flv' ) ) {
|
||||
return '<a href="' + node.src + '">' + mejsL10n.strings['mejs.download-video'] + '</a>';
|
||||
}
|
||||
};
|
||||
|
||||
// Only initialize new media elements.
|
||||
$( '.wp-audio-shortcode, .wp-video-shortcode' )
|
||||
.not( '.mejs-container' )
|
||||
|
Loading…
x
Reference in New Issue
Block a user