Fix compatibility with the lazy module

Created on 30 January 2021, over 3 years ago
Updated 25 January 2023, over 1 year ago

Problem/Motivation

If I use the lazy module, the pages don't validate.
Through attribute: loading="lazy"
I found an easy way to make the two modules compatible.

Steps to reproduce

Turn on AMP and lazy .

Proposed resolution

In file amp-image-wrapper.html.twig Replace:

{#
/**
 * @file
 * Theme override of an image.
 *
 * Available variables:
 * - attributes: HTML attributes for the img tag.
 * - style_name: (optional) The name of the image style applied.
 *
 * @see template_preprocess_amp_components_image()
 */
#}
<amp-img{{ attributes }}></amp-img>

On .removeAttribute('loading')

{#
/**
 * @file
 * Theme override of an image.
 *
 * Available variables:
 * - attributes: HTML attributes for the img tag.
 * - style_name: (optional) The name of the image style applied.
 *
 * @see template_preprocess_amp_components_image()
 */
#}
<amp-img{{ attributes.removeAttribute('loading') }}></amp-img>
πŸ“Œ Task
Status

Needs review

Version

3.5

Component

Code

Created by

πŸ‡ΊπŸ‡¦Ukraine Devoleksiy

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.69.0 2024