File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -2172,11 +2172,29 @@ var Reveal = (function(){
21722172 */
21732173 function loadSlide ( slide ) {
21742174
2175- toArray ( slide . querySelectorAll ( 'img[data-src]' ) ) . forEach ( function ( element ) {
2175+ // Media elements with data-src attributes
2176+ toArray ( slide . querySelectorAll ( 'img[data-src], video[data-src]' ) ) . forEach ( function ( element ) {
21762177 element . setAttribute ( 'src' , element . getAttribute ( 'data-src' ) ) ;
21772178 element . removeAttribute ( 'data-src' ) ;
21782179 } ) ;
21792180
2181+ // Video elements with multiple <source>s
2182+ toArray ( slide . querySelectorAll ( 'video' ) ) . forEach ( function ( video ) {
2183+ var sources = 0 ;
2184+
2185+ toArray ( slide . querySelectorAll ( 'source[data-src]' ) ) . forEach ( function ( source ) {
2186+ source . setAttribute ( 'src' , source . getAttribute ( 'data-src' ) ) ;
2187+ source . removeAttribute ( 'data-src' ) ;
2188+ sources += 1 ;
2189+ } ) ;
2190+
2191+ // If we rewrote sources for this video, we need to manually
2192+ // tell it to load from its new origin
2193+ if ( sources > 0 ) {
2194+ video . load ( ) ;
2195+ }
2196+ } ) ;
2197+
21802198 }
21812199
21822200 /**
You can’t perform that action at this time.
0 commit comments