Skip to content

Commit c6c4b51

Browse files
authored
Merge pull request #63 from timvink/60_disable_lazy_loading
Attempt to disable lazy loading
2 parents 52fd293 + 13c0ced commit c6c4b51

File tree

6 files changed

+25
-5
lines changed

6 files changed

+25
-5
lines changed

mkdocs_print_site_plugin/js/print-site.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,4 +146,4 @@ function remove_element_by_classname(class_name) {
146146
if( el.length > 0) {
147147
el[0].style.display = "none"
148148
}
149-
}
149+
}

mkdocs_print_site_plugin/plugin.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -309,6 +309,10 @@ def on_post_build(self, config, **kwargs):
309309
# Render the theme template for the print page
310310
html = template.render(self.context)
311311

312+
# Remove lazy loading attributes from images
313+
# https://regex101.com/r/HVpKPs/1
314+
html = re.sub(r"(\<img.+)(loading=\"lazy\")", r"\1", html)
315+
312316
# Compatiblity with mkdocs-chart-plugin
313317
# As this plugin adds some javascript to every page
314318
# It should be included in the print site also

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
setup(
1111
name="mkdocs-print-site-plugin",
12-
version="2.2.3",
12+
version="2.2.4",
1313
description="MkDocs plugin that combines all pages into one, allowing for easy export to PDF and standalone HTML.",
1414
long_description=long_description,
1515
long_description_content_type="text/markdown",

tests/fixtures/projects/basic/docs/index.md

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,12 @@ An to an anchor on page A [link](a.md#anchor-links)
99

1010
## Subsection
1111

12-
On the homepage
12+
On the homepage
13+
14+
## An image with lazy loading
15+
16+
See https://github.com/timvink/mkdocs-print-site-plugin/issues/60
17+
18+
![Image title](https://dummyimage.com/600x400/){ loading=lazy }
19+
20+

tests/fixtures/projects/basic/mkdocs_material_instant_loading.yml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,8 @@ plugins:
1313
nav:
1414
- Home: index.md
1515
- Page Z: z.md
16-
- Page A: a.md
16+
- Page A: a.md
17+
18+
markdown_extensions:
19+
- attr_list
20+
- md_in_html

tests/fixtures/projects/basic/mkdocs_material_with_git_plugin.yml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,8 @@ plugins:
1212
nav:
1313
- Home: index.md
1414
- Page Z: z.md
15-
- Page A: a.md
15+
- Page A: a.md
16+
17+
markdown_extensions:
18+
- attr_list
19+
- md_in_html

0 commit comments

Comments
 (0)