#57722 closed defect (bug) (invalid)
Loading property cannot be disabled in wp_get_attachment_image
Reported by: | AlexHolsgrove | Owned by: | |
---|---|---|---|
Milestone: | Priority: | normal | |
Severity: | normal | Version: | 6.1.1 |
Component: | Media | Keywords: | |
Focuses: | Cc: |
Description
In function wp_get_attachment_image()
the docs suggest you can pass boolean “false” as part of the $attr for "loading" so that the attribute is omitted.
An example is also given in this article: https://make.wordpress.org/core/2020/07/14/lazy-loading-images-in-5-5/
<?php echo wp_get_attachment_image( 42, 'large', false, array( 'loading' => false ), );
However the property is still added (as loading="lazy"), caused by wp-includes/media.php function wp_filter_content_tags()
.
Change History (4)
#2
@
22 months ago
- Resolution set to invalid
- Status changed from new to closed
Thanks @costdev - your test shows the function working correctly. I also moved this to my front-end template and also worked correctly.
I can repeat my issue, however if I place the code inside a Gutenberg block template, using Advanced Custom Fields, so I believe the issue is with their plugin calling one of the filters.
Happy to close this as a non-issue.
Reproduction Report
This report validates that the issue can be reproduced.
Steps to Reproduce or Test
Media > Add New
and upload an image.wp-content/plugins/test_wp_get_attachment_image.php
with the following contents:Plugins > Installed plugins
and activate "Testwp_get_attachment_image()
".Expected Results
loading="lazy"
attribute is still added.Environment
Actual Results
Notes