diff --git a/public/typo3conf/ext/ep_theme/Classes/ViewHelpers/LazyLoadImageViewHelper.php b/public/typo3conf/ext/ep_theme/Classes/ViewHelpers/LazyLoadImageViewHelper.php new file mode 100644 index 00000000..37387929 --- /dev/null +++ b/public/typo3conf/ext/ep_theme/Classes/ViewHelpers/LazyLoadImageViewHelper.php @@ -0,0 +1,47 @@ +registerArgument('loaderimg', 'string', '', false); + } + + public function render(): string + { + parent::render(); + + $src = $this->tag->getAttribute('src'); + $this->tag->removeAttribute('src'); + $this->tag->addAttribute('data', ['src' => $src]); + + if (isset($this->arguments['loaderimg'])) { + $loaderImage = $this->imageService->getImage($this->arguments['loaderimg'], null, false); + $processingInstructions = [ + 'width' => $this->arguments['width'], + 'height' => $this->arguments['height'], + 'minWidth' => $this->arguments['minWidth'], + 'minHeight' => $this->arguments['minHeight'], + 'maxWidth' => $this->arguments['maxWidth'], + 'maxHeight' => $this->arguments['maxHeight'], + ]; + $processedLoaderImage = $this->imageService->applyProcessingInstructions($loaderImage, $processingInstructions); + $loaderImageUri = $this->imageService->getImageUri($processedLoaderImage, $this->arguments['absolute']); + $this->tag->addAttribute('src', $loaderImageUri); + } + + $classes = $this->tag->getAttribute('class'); + $classItems = GeneralUtility::trimExplode(' ', $classes, true); + $classItems[] = 'lazyload'; + $classes = implode(' ', array_unique($classItems)); + $this->tag->addAttribute('class', $classes); + + return $this->tag->render(); + } +} diff --git a/public/typo3conf/ext/ep_theme/Resources/Private/Partials/Officetip.html b/public/typo3conf/ext/ep_theme/Resources/Private/Partials/Officetip.html index 6d7845e2..f65ecb58 100644 --- a/public/typo3conf/ext/ep_theme/Resources/Private/Partials/Officetip.html +++ b/public/typo3conf/ext/ep_theme/Resources/Private/Partials/Officetip.html @@ -8,14 +8,11 @@