Created
May 6, 2020 08:31
-
-
Save Sebobo/6e58acf6cffa2aded47021cc272b7f2c to your computer and use it in GitHub Desktop.
How to enable native lazy loading for all images in Neos CMS
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Modify all image tags and add the attribute | |
prototype(Neos.Neos:ImageTag) { | |
attributes.loading = 'lazy' | |
} | |
# Example on the usage, see https://fusionpen.punkt.de/fusionpen/4e19425fc39184b13790ff00e8ce1c10328fa36d.html | |
prototype(YourVendor:LazyImageDemo) < prototype(Neos.Fusion:Component) { | |
chapters = ${q(site).find('[instanceof Neos.Demo:Document.Chapter]').get()} | |
renderer = afx` | |
<div> | |
<h1>Responsive images!</h1> | |
<Neos.Fusion:Loop items={props.chapters}> | |
<section> | |
<h2>{q(item).property('title')}</h2> | |
<Neos.Neos:ImageTag asset={q(item).property('chapterImage')} /> | |
</section> | |
</Neos.Fusion:Loop> | |
</div> | |
` | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment