Use lazy loading for reveal.js slide shows.
* In HTML writer, with reveal.js we use data-src instead of src for images. * In SelfContained, we also load resources from data-src. Closes #2283.
This commit is contained in:
parent
8b9448aa17
commit
612f1238aa
2 changed files with 19 additions and 8 deletions
|
@ -73,7 +73,7 @@ convertTag media sourceURL t@(TagOpen tagname as)
|
|||
as' <- mapM processAttribute as
|
||||
return $ TagOpen tagname as'
|
||||
where processAttribute (x,y) =
|
||||
if x == "src" || x == "href" || x == "poster"
|
||||
if x == "src" || x == "data-src" || x == "href" || x == "poster"
|
||||
then do
|
||||
enc <- getDataURI media sourceURL (fromAttrib "type" t) y
|
||||
return (x, enc)
|
||||
|
|
|
@ -953,7 +953,13 @@ inlineToHtml opts inline = do
|
|||
else link'' ! A.title (toValue tit)
|
||||
(Image attr txt (s,tit)) | treatAsImage s -> do
|
||||
let alternate' = stringify txt
|
||||
let attributes = [A.src $ toValue s] ++
|
||||
slideVariant <- gets stSlideVariant
|
||||
let isReveal = slideVariant == RevealJsSlides
|
||||
let attributes =
|
||||
-- reveal.js uses data-src for lazy loading
|
||||
(if isReveal
|
||||
then customAttribute "data-src" $ toValue s
|
||||
else A.src $ toValue s) :
|
||||
[A.title $ toValue tit | not (null tit)] ++
|
||||
[A.alt $ toValue alternate' | not (null txt)] ++
|
||||
imgAttrsToHtml opts attr
|
||||
|
@ -961,7 +967,12 @@ inlineToHtml opts inline = do
|
|||
return $ foldl (!) tag attributes
|
||||
-- note: null title included, as in Markdown.pl
|
||||
(Image attr _ (s,tit)) -> do
|
||||
let attributes = [A.src $ toValue s] ++
|
||||
slideVariant <- gets stSlideVariant
|
||||
let isReveal = slideVariant == RevealJsSlides
|
||||
let attributes =
|
||||
(if isReveal
|
||||
then customAttribute "data-src" $ toValue s
|
||||
else A.src $ toValue s) :
|
||||
[A.title $ toValue tit | not (null tit)] ++
|
||||
imgAttrsToHtml opts attr
|
||||
return $ foldl (!) H5.embed attributes
|
||||
|
|
Loading…
Reference in a new issue