[wp-trac] [WordPress Trac] #58894: Enhance `wp_get_loading_optimization_attributes()` to support arbitrary context values

WordPress Trac noreply at wordpress.org
Mon Sep 18 14:53:52 UTC 2023


#58894: Enhance `wp_get_loading_optimization_attributes()` to support arbitrary
context values
--------------------------------------+--------------------------
 Reporter:  flixos90                  |       Owner:  mukesh27
     Type:  enhancement               |      Status:  closed
 Priority:  normal                    |   Milestone:  6.4
Component:  Media                     |     Version:
 Severity:  normal                    |  Resolution:  fixed
 Keywords:  has-patch has-unit-tests  |     Focuses:  performance
--------------------------------------+--------------------------
Changes (by flixos90):

 * status:  assigned => closed
 * resolution:   => fixed


Comment:

 In [changeset:"56612" 56612]:
 {{{
 #!CommitTicketReference repository="" revision="56612"
 Media: Enhance `wp_get_loading_optimization_attributes()` to support
 arbitrary context values.

 The `wp_get_loading_optimization_attributes()` function, which was
 introduced in 6.3, based on the now deprecated
 `wp_get_loading_attr_default()` function introduced in 5.5, relies on a
 `$context` parameter based on which it may alter its behavior and the
 attributes returned. So far, it has only supported context values used
 within WordPress core.

 This changeset decouples the behaviors of the function from specific
 contexts, allowing for more flexibility. Theme and plugin developers will
 be able to rely on their own context values when rendering images in non-
 standard ways, rather than being forced to use a core context, to get the
 loading optimization benefits the function provides.

 As part of this change, a `wp_loading_optimization_force_header_contexts`
 filter is introduced, which allows filtering the map of context values and
 whether they should be considered header contexts, i.e. i.e. any image
 having one of these contexts will be assumed to appear above the fold.

 Props mukesh27, costdev, flixos90.
 Fixes #58894.
 }}}

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/58894#comment:15>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list