consider lazy loaded iframes when formatting src
This commit is contained in:
parent
e16a220a62
commit
5f90a449cf
23
js/reveal.js
23
js/reveal.js
@ -2871,21 +2871,22 @@
|
|||||||
*/
|
*/
|
||||||
function formatEmbeddedContent() {
|
function formatEmbeddedContent() {
|
||||||
|
|
||||||
// YouTube frames must include "?enablejsapi=1"
|
var _appendParamToIframeSource = function( sourceAttribute, sourceURL, param ) {
|
||||||
toArray( dom.slides.querySelectorAll( 'iframe[src*="youtube.com/embed/"]' ) ).forEach( function( el ) {
|
toArray( dom.slides.querySelectorAll( 'iframe['+ sourceAttribute +'*="'+ sourceURL +'"]' ) ).forEach( function( el ) {
|
||||||
var src = el.getAttribute( 'src' );
|
var src = el.getAttribute( sourceAttribute );
|
||||||
if( !/enablejsapi\=1/gi.test( src ) ) {
|
if( src && src.indexOf( param ) === -1 ) {
|
||||||
el.setAttribute( 'src', src + ( !/\?/.test( src ) ? '?' : '&' ) + 'enablejsapi=1' );
|
el.setAttribute( sourceAttribute, src + ( !/\?/.test( src ) ? '?' : '&' ) + param );
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
// YouTube frames must include "?enablejsapi=1"
|
||||||
|
_appendParamToIframeSource( 'src', 'youtube.com/embed/', 'enablejsapi=1' );
|
||||||
|
_appendParamToIframeSource( 'data-src', 'youtube.com/embed/', 'enablejsapi=1' );
|
||||||
|
|
||||||
// Vimeo frames must include "?api=1"
|
// Vimeo frames must include "?api=1"
|
||||||
toArray( dom.slides.querySelectorAll( 'iframe[src*="player.vimeo.com/"]' ) ).forEach( function( el ) {
|
_appendParamToIframeSource( 'src', 'player.vimeo.com/', 'api=1' );
|
||||||
var src = el.getAttribute( 'src' );
|
_appendParamToIframeSource( 'data-src', 'player.vimeo.com/', 'api=1' );
|
||||||
if( !/api\=1/gi.test( src ) ) {
|
|
||||||
el.setAttribute( 'src', src + ( !/\?/.test( src ) ? '?' : '&' ) + 'api=1' );
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user