Skip to content

Commit

Permalink
Merge pull request #39 from magefan/9522-fix-issue-with-few-pixel-src
Browse files Browse the repository at this point in the history
9522 fixed issue with few pixel src in image tag when lazy load added…
  • Loading branch information
magefan authored Oct 5, 2023
2 parents 47b0bb0 + 19e2791 commit bd37a6c
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion Plugin/BlockPlugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -102,10 +102,14 @@ public function afterToHtml(\Magento\Framework\View\Element\AbstractBlock $block
*/
private function prepareForJsLazyLoad($block, string $html): string
{
$lazyAttribute = ' data-original=';

$pixelSrc = ' src="' . $block->getViewFileUrl('Magefan_LazyLoad::images/pixel.jpg') . '"';
$tmpSrc = 'TMP_SRC';
$tmpDataOriginal = 'TMP_DATA_ORIGINAL';

$html = str_replace($pixelSrc, $tmpSrc, $html);
$html = str_replace($lazyAttribute, $tmpDataOriginal, $html);

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

$html = str_replace(' data-original=', $pixelSrc . ' data-original=', $html);
$html = str_replace($lazyAttribute, $pixelSrc . $lazyAttribute, $html);

$html = str_replace($tmpSrc, $pixelSrc, $html);
$html = str_replace($tmpDataOriginal, $lazyAttribute, $html);
$html = str_replace(self::LAZY_TAG, '', $html);

/* Disable Owl Slider LazyLoad */
Expand Down

0 comments on commit bd37a6c

Please sign in to comment.