Skip to content

Commit 334fb38

Browse files
committed
1 parent b12a2cd commit 334fb38

File tree

3 files changed

+13
-2
lines changed

3 files changed

+13
-2
lines changed

Plugin/BlockPlugin.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,11 @@ public function afterToHtml(\Magento\Framework\View\Element\AbstractBlock $block
7878
$html = str_replace($pixelSrc, $tmpSrc, $html);
7979

8080
$html = preg_replace('#<img\s+([^>]*)(?:src="([^"]*)")([^>]*)\/?>#isU', '<img ' . $pixelSrc .
81-
' data-original="$2" $1 $3/>', $html);
81+
' data-original="$2" $1 $3/>
82+
<noscript>
83+
<img src="$2" $1 $3 />
84+
</noscript>
85+
', $html);
8286

8387
$html = str_replace($tmpSrc, $pixelSrc, $html);
8488
$html = str_replace(self::LAZY_TAG, '', $html);

view/frontend/layout/default.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
-->
1010
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
1111
<body>
12+
<attribute name="class" value="mflazyzoad-no-js" />
1213
<referenceBlock name="after.body.start">
1314
<block class="Magefan\LazyLoad\Block\Lazy" name="magefan.lazyload" template="Magefan_LazyLoad::lazy.phtml" >
1415
<arguments>

view/frontend/templates/lazy.phtml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,15 @@
66
* Glory to Ukraine! Glory to the heroes!
77
*/
88
?>
9-
9+
<style>
10+
.mflazyzoad-no-js [data-original],
11+
.mflazyzoad-no-js [data-originalset] {
12+
display: none;
13+
}
14+
</style>
1015
<script data-rocketjavascript="false">
1116
(function(){
17+
document.body.className = document.body.className.replace('mflazyzoad-no-js', '');
1218
var jsSrc = '<?php echo $this->getViewFileUrl('Magefan_LazyLoad::js/lazyload.min.js'); ?>'
1319
function loadScript(e,t){var a,n,r;n=!1,(a=document.createElement("script")).type="text/javascript",a.src=e,a.onload=a.onreadystatechange=function(){n||this.readyState&&"complete"!=this.readyState||(n=!0,t())},(r=document.getElementsByTagName("script")[0]).parentNode.insertBefore(a,r)}
1420
loadScript(jsSrc, function(){

0 commit comments

Comments
 (0)