diff options
author | Andrew Dolgov <[email protected]> | 2020-12-11 09:22:30 +0300 |
---|---|---|
committer | Andrew Dolgov <[email protected]> | 2020-12-11 09:22:30 +0300 |
commit | 43bd3394c31ed67cafddd2c147144bdb67f32477 (patch) | |
tree | 47491aadaa3f870da7433f577632af33b4e2f414 | |
parent | 71c8d8d365f62ecacceaee9f5fe70c344a18dd4b (diff) |
shorten_expanded: remove loading=lazy from images if enabled
-rw-r--r-- | plugins/shorten_expanded/init.js | 2 | ||||
-rw-r--r-- | plugins/shorten_expanded/init.php | 17 |
2 files changed, 17 insertions, 2 deletions
diff --git a/plugins/shorten_expanded/init.js b/plugins/shorten_expanded/init.js index 587fcea42..30bfac6ba 100644 --- a/plugins/shorten_expanded/init.js +++ b/plugins/shorten_expanded/init.js @@ -37,7 +37,7 @@ require(['dojo/_base/kernel', 'dojo/ready'], function (dojo, ready) { c_inner.innerHTML = `<div class="content-shrink-wrap"> ${c_inner.innerHTML} - ${tmp.innerHTML}</div> + ${tmp.innerHTML}</div> <button dojoType="dijit.form.Button" class="alt-info expand-prompt" onclick="return Plugins.Shorten_Expanded.expand('${row.id}')" href="#"> ${__("Click to expand article")}</button>`; diff --git a/plugins/shorten_expanded/init.php b/plugins/shorten_expanded/init.php index 64b4ad7ab..f816a838d 100644 --- a/plugins/shorten_expanded/init.php +++ b/plugins/shorten_expanded/init.php @@ -11,6 +11,21 @@ class Shorten_Expanded extends Plugin { function init($host) { $this->host = $host; + $host->add_hook($host::HOOK_SANITIZE, $this); + } + + // native lazy loading messes with plugin height calculation because images get loaded + // after headline is actually rendered (off screen) so we force disable it + function hook_sanitize($doc) { + $xpath = new DOMXPath($doc); + + $entries = $xpath->query('(//*[@loading="lazy"])'); + + foreach ($entries as $entry) { + $entry->removeAttribute("loading"); + } + + return $doc; } function get_css() { @@ -25,4 +40,4 @@ class Shorten_Expanded extends Plugin { return 2; } -}
\ No newline at end of file +} |