Skip to content

Instantly share code, notes, and snippets.

@Sebobo
Created May 6, 2020 08:31
Show Gist options
  • Save Sebobo/6e58acf6cffa2aded47021cc272b7f2c to your computer and use it in GitHub Desktop.
Save Sebobo/6e58acf6cffa2aded47021cc272b7f2c to your computer and use it in GitHub Desktop.
How to enable native lazy loading for all images in Neos CMS
# 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