Skip to content

Commit bd37a6c

Browse files
authored
Merge pull request #39 from magefan/9522-fix-issue-with-few-pixel-src
9522 fixed issue with few pixel src in image tag when lazy load added…
2 parents 47b0bb0 + 19e2791 commit bd37a6c

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

Plugin/BlockPlugin.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,10 +102,14 @@ public function afterToHtml(\Magento\Framework\View\Element\AbstractBlock $block
102102
*/
103103
private function prepareForJsLazyLoad($block, string $html): string
104104
{
105+
$lazyAttribute = ' data-original=';
106+
105107
$pixelSrc = ' src="' . $block->getViewFileUrl('Magefan_LazyLoad::images/pixel.jpg') . '"';
106108
$tmpSrc = 'TMP_SRC';
109+
$tmpDataOriginal = 'TMP_DATA_ORIGINAL';
107110

108111
$html = str_replace($pixelSrc, $tmpSrc, $html);
112+
$html = str_replace($lazyAttribute, $tmpDataOriginal, $html);
109113

110114
$noscript = '';
111115
if ($this->config->isNoScriptEnabled()) {
@@ -120,9 +124,10 @@ private function prepareForJsLazyLoad($block, string $html): string
120124
$html
121125
);
122126

123-
$html = str_replace(' data-original=', $pixelSrc . ' data-original=', $html);
127+
$html = str_replace($lazyAttribute, $pixelSrc . $lazyAttribute, $html);
124128

125129
$html = str_replace($tmpSrc, $pixelSrc, $html);
130+
$html = str_replace($tmpDataOriginal, $lazyAttribute, $html);
126131
$html = str_replace(self::LAZY_TAG, '', $html);
127132

128133
/* Disable Owl Slider LazyLoad */

0 commit comments

Comments
 (0)