[wp-trac] [WordPress Trac] #56295: filter wp_content_img_tag runs multiple times
WordPress Trac
noreply at wordpress.org
Tue Aug 9 17:44:08 UTC 2022
#56295: filter wp_content_img_tag runs multiple times
--------------------------------+------------------------------
Reporter: gigito78 | Owner: (none)
Type: defect (bug) | Status: new
Priority: normal | Milestone: Awaiting Review
Component: Media | Version: 6.0
Severity: normal | Resolution:
Keywords: needs-testing-info | Focuses:
--------------------------------+------------------------------
Comment (by gigito78):
Hello @ironprogrammer!
Tried to setup a site to help you to reproduce the problem:
1. https://www.gigitopcinformatica.it/test4/hello-world/
theme active: wordpress twenty-twentytwo, inserted in function.php the
code:
{{{
add_filter( $hook_name='wp_content_img_tag', function( $filtered_image,
$context, $attachment_id ){
$timestamp_mediapost = get_post_modified_time( $format='U', $gmt=true,
$post=$attachment_id, $translate=false );
$filtered_image = str_replace( $search='.webp',
$replace='.webp?='.$timestamp_mediapost, $subject=$filtered_image,
$count);
echo $count.'-';
return $filtered_image; },$priority=21, $accepted_args=3 );
}}}
Objective: add query strings to webp files. Please use console to look at
filtered images code ad look to the top the echoed $count parameter. Seem
that the order is: custom logo image, then content image, then custom logo
image again, the, content image again.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/56295#comment:4>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list