[wp-trac] [WordPress Trac] #56588: WordPress puts "loading=lazy" on first image on archive page - wp_get_loading_attr_default bug
WordPress Trac
noreply at wordpress.org
Thu Apr 6 06:44:40 UTC 2023
#56588: WordPress puts "loading=lazy" on first image on archive page -
wp_get_loading_attr_default bug
-------------------------------+--------------------------
Reporter: salvoaranzulla | Owner: flixos90
Type: defect (bug) | Status: assigned
Priority: normal | Milestone: 6.3
Component: Media | Version: 5.9
Severity: normal | Resolution:
Keywords: reporter-feedback | Focuses: performance
-------------------------------+--------------------------
Comment (by salvoaranzulla):
Hi,
Here is an update with latest WordPress version (6.2). I confirm that the
bug is also in the last version of WordPress.
1) On wp-includes/media.php I have added:
{{{#!php
<?php
print_r($content_media_count); // added to see the counter
}}}
after
{{{#!php
<?php
// Increase the counter since this is a main query content element.
$content_media_count = wp_increase_content_media_count();
}}}
On my archive page, I see:
[https://core.trac.wordpress.org/attachment/ticket/56588/Screenshot%202023-04-06%20alle%2008.41.46.png]
2) My archive code page is the following:
{{{
<?php
$p = 0;
$i = 0;
while ( have_posts() ) : the_post();
if($p == 0):
?>
<article class="contentPreview">
<header>
<a href="<?php the_permalink(); ?>"><span
class="heading2"><?php the_title(); ?></span></a>
</header>
<p class="column"><?php the_excerpt(); ?></p>
<figure class="column">
<?php the_post_thumbnail('home-bottom',
array( 'alt' => get_the_title())) ?>
</figure>
</article>
<div class="articleGrid">
<?php
else:
if ($i % 2 == 0) echo '<div class="row">';
?>
<article class="contentPreview column">
<header>
<a href="<?php
the_permalink(); ?>"><span class="heading4"><?php the_title();
?></span></a>
</header>
<p class="small"><?php
the_excerpt(); ?></p>
</article>
<?php
if ($i % 2 != 0) echo '</div>';
$i++;
?>
<?php endif; $p++; endwhile; ?>
</div>
}}}
3) The "loading=lazy" has been added to the images because WordPress
thinks that the image is the image number 10 (my post has 9 images
inside).
--
Ticket URL: <https://core.trac.wordpress.org/ticket/56588#comment:10>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list