[wp-trac] [WordPress Trac] #56056: Specify a Custom Array of $sizes for `wp_get_attachment_image` to Reduce HTML Bloat
WordPress Trac
noreply at wordpress.org
Thu Jun 23 15:44:50 UTC 2022
#56056: Specify a Custom Array of $sizes for `wp_get_attachment_image` to Reduce
HTML Bloat
-----------------------------+-----------------------------
Reporter: xmic | Owner: (none)
Type: enhancement | Status: new
Priority: normal | Milestone: Awaiting Review
Component: Post Thumbnails | Version: trunk
Severity: normal | Keywords: needs-patch
Focuses: performance |
-----------------------------+-----------------------------
Plugins and the theme can specify multiple thumbnail sizes. Using
`wp_get_attachment_image` provides a modern solution to responsive image
sizes, however, it does not currently account for reducing the bloat to
all the registered thumbnail sizes that are added by plugins / theme.
Therefore a proposal is to allow a custom list of thumbnails to use, this
can, for example, be specified as:
{{{#!php
<?php
wp_get_attachment_image(123, [['thumbnail', [1200, 630], 'medium',
'large'], true]);
}}}
Where the `true` is to identify that we want to enable a specified list of
thumbnail sizes, and not use all of the thumbnail sizes registered.
It will only loop through the specified `$sizes` that were mentioned in
the $sizes parameter.
HTML document size is a large factor in determining if a website is to be
bloated or not. Therefore it would be beneficial to allow developers to
specify specific thumbnail sizes that are to be used for what it is
intended for.
Kind regards,
Michael
--
Ticket URL: <https://core.trac.wordpress.org/ticket/56056>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list