Make WordPress Core

Opened 17 months ago

Closed 17 months ago

Last modified 16 months ago

#57490 closed defect (bug) (fixed)

Cannot control lazy-loading behavior on a featured image

Reported by: flixos90's profile flixos90 Owned by: flixos90's profile flixos90
Milestone: 6.2 Priority: normal
Severity: normal Version: 5.5
Component: Media Keywords: has-patch has-unit-tests add-to-field-guide
Focuses: performance Cc:

Description

When lazy-loading was introduced in WordPress 5.5, one crucial customization point that was omitted (by accident) is checking whether lazy-loading is enabled for a featured image.

As first reported in https://github.com/WordPress/gutenberg/issues/46789, this means that it is impossible to control or remove loading="lazy" attributes added to featured images.

The Gutenberg issue also refers to other problems some of which are subject of #56930, but technically those problems are separate from this one.

Change History (6)

This ticket was mentioned in PR #3857 on WordPress/wordpress-develop by @flixos90.


17 months ago
#1

  • Keywords has-patch has-unit-tests added; needs-patch needs-unit-tests removed

#2 @flixos90
17 months ago

@adamsilverstein @joemcgill @mukesh27 Could you maybe take a look at this? The fix is pretty straightforward.

@flixos90 commented on PR #3857:


17 months ago
#3

@joemcgill Fair point, it may be (or have been) a good idea to call wp_lazy_loading_enabled() in wp_get_loading_attr_default(), so that consuming code would have only needed to call the latter. However, the second function was only introduced later, and at this point I'm not sure we could make such a change without breaking BC.

#4 @flixos90
17 months ago

  • Resolution set to fixed
  • Status changed from assigned to closed

In 55093:

Media: Allow for customization of lazy-loading featured images.

When lazy-loading images was introduced, in [52065] the check for wp_lazy_loading_enabled() was omitted by accident in the logic to set the attribute with its default value on img tags from get_the_post_thumbnail(). Without this check, it is impossible for third-party developers to modify the behavior for featured images.

This changeset fixes the problem by introducing the check.

Props flixos90, joemcgill, mukesh27.
Fixes #57490.

#6 @milana_cap
16 months ago

  • Keywords add-to-field-guide added
Note: See TracTickets for help on using tickets.