[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:31:11 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             |  Resolution:
 Keywords:  reporter-feedback  |     Focuses:
-------------------------------+------------------------------
Changes (by costdev):

 * keywords:   => reporter-feedback


Comment:

 == Reproduction Report
 This report validates that the issue can be reproduced.

 === Steps to Reproduce or Test
 1. Navigate to `Media > Add New` and upload an image.
 2. Create a new file: `wp-
 content/plugins/test_wp_get_attachment_image.php` with the following
 contents:
 {{{#!php
 <?php

 /**
  * Plugin Name: Test <code>wp_get_attachment_image()</code>
  * Description: Tests <code>wp_get_attachment_image()</code>.
  * Author:      WordPress Core Contributors
  * Author URI:  https://make.wordpress.org/core
  * License:     GPLv2 or later
  * Version:     1.0.0
  */

 add_action(
         'admin_notices',
         function() {
                 $attachment = get_posts(
                         array(
                                 'orderby'        => 'rand',
                                 'numberposts'    => 1,
                                 'post_type'      => 'attachment',
                                 'post_mime_type' => 'image',
                                 'post_status'    => 'inherit',
                         )
                 );

                 $image = wp_get_attachment_image(
                         $attachment[0]->ID,
                         'large',
                         false,
                         array( 'loading' => false ),
                 );

                 printf(
                         '<div class="notice notice-info">%s</div>',
                         esc_html( $image )
                 );
         }
 );
 }}}
 3. Navigate to `Plugins > Installed plugins` and activate Test
 `wp_get_attachment_image()`.
 4. Check the output in the admin notice.

 === Expected Results
 - 🐞 The `loading="lazy"` attribute is still added.

 === Environment
 * Server: Apache (Linux)
 * WordPress: 6.2-beta2-55340-src and WordPress 6.1.1
 * Browser: Chrome 109.0.0.0
 * OS: Windows 10
 * Theme: Twenty Twenty-Two
 * Plugins:
   * Test wp_get_attachment_image() 1.0.0

 === Actual Results
 - ❌ Could not reproduce on WordPress 6.2-beta2-55340-src or WordPress
 6.1.1.

 === Notes
 - @AlexHolsgrove Is there any information missing from your report, or my
 steps above, to reproduce this issue?

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


More information about the wp-trac mailing list