Add Support for Custom Image Sizes in wp_get_attachment_image to Reduce HTML Bloat#6930
Add Support for Custom Image Sizes in wp_get_attachment_image to Reduce HTML Bloat#6930geekofshire wants to merge 1 commit intoWordPress:trunkfrom
Conversation
|
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the Unlinked AccountsThe following contributors have not linked their GitHub and WordPress.org accounts: @rohanjha@Rohans-MacBook-Air.local. Contributors, please read how to link your accounts to ensure your work is properly credited in WordPress releases. To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
Test using WordPress PlaygroundThe changes in this pull request can previewed and tested using a WordPress Playground instance. WordPress Playground is an experimental project that creates a full WordPress instance entirely within the browser. Some things to be aware of
For more details about these limitations and more, check out the Limitations page in the WordPress Playground documentation. |
Summary
This PR introduces a new feature to the
wp_get_attachment_imagefunction, allowing developers to specify a custom list of image sizes to be included in the HTML output. This helps in reducing HTML bloat by including only the necessary image sizes.Changes
$use_custom_sizesparameter to thewp_get_attachment_imagefunction.boolfalsetrueand an array of sizes is provided in the$sizeparameter, only those specified sizes are included.$use_custom_sizesistrue.$use_custom_sizesistrueand$sizeis an array, it processes each specified size individually.$use_custom_sizesisfalse, it behaves as before, using the single size provided.Benefits
Example Usage
Trac ticket: https://core.trac.wordpress.org/ticket/56056