[wp-trac] [WordPress Trac] #57722: Loading property cannot be disabled in wp_get_attachment_image

WordPress Trac noreply at wordpress.org
Tue Feb 14 21:17:53 UTC 2023


#57722: Loading property cannot be disabled in wp_get_attachment_image
---------------------------+-----------------------------
 Reporter:  AlexHolsgrove  |      Owner:  (none)
     Type:  defect (bug)   |     Status:  new
 Priority:  normal         |  Milestone:  Awaiting Review
Component:  General        |    Version:  6.1.1
 Severity:  normal         |   Keywords:
  Focuses:                 |
---------------------------+-----------------------------
 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
 <?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()`.

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/57722>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list