Closed stuible closed 2 years ago
Using Twig, this could be achieved with the attr
filter:
{{ craft.embeddedAssets.get(element.embeddedAsset.one()).html|attr({ loading: 'lazy' }) }}
It makes sense for this to be an in-built option for the embedded asset getIframeCode()
method, though, so will look at adding that soon.
Just released Embedded Assets 3.0.4 with a second parameter for getIframeCode()
for adding attributes to iframes, in the format attribute
or attribute=value
(see the templating documentation for an example).
Description
It would be great if we could opt for lazy loading iframe embeds which could improve website loading performance. Alternatively, it would be awesome if we could append custom attributes to the iframe element in twig.
Love the plugin so far!