Florian
Forum Replies Created
-
Forum: Everything else WordPress
In reply to: Remove sizes=”auto, …” in WordPress 6.7There also seems to be a filter, maybe try that first!
Drop this in your theme to disable
auto
in thesizes
attribute:add_filter('wp_img_tag_add_auto_sizes', '__return_false');
Forum: Everything else WordPress
In reply to: Remove sizes=”auto, …” in WordPress 6.7If you want to keep lazy loading enabled and remove only the
auto
part do this:add_filter(
'wp_content_img_tag',
static function ( $image ) {
return str_replace( ' sizes="auto, ', ' sizes="', $image );
}
);
add_filter(
'wp_get_attachment_image_attributes',
static function ( $attr ) {
if ( isset( $attr['sizes'] ) ) {
$attr['sizes'] = preg_replace( '/^auto, /', '', $attr['sizes'] );
}
return $attr;
}
);Nabbed from a trac discussion.
- This reply was modified 3 months, 1 week ago by Florian.
Yes, updating the plugin solved it for me.
Yes, I can see the issue on that site when I view it in Safari. I can’t tell you what causes it, that would take too long to figure out as there’s a TON of javascript on your page.
You say it goes away when you deactivate GTM4WP. That could be related to scripts in the plugin, but it could also be related to stuff you do in your GTM container.
A pain in the butt to debug, you just have to step through all of the stuff that gets loaded on your page until you find the culprit.
I cannot reproduce this behavior.
Both of these issues seem to be unrelated to the topic of this thread: “Safari Back Button Reloading Issue”. I would suggest you create new topics for your new issues.
The code causing this has been removed from the GTM4WP plugin in version 1.16.2.
– check if you have updated the plugin
– check if other plugins / template code might be causing this
– check for cachingThis behavior is expected, GTM4WP injects this code on every page:
<script> const gtm4wp_is_safari = /^((?!chrome|android).)*safari/i.test(navigator.userAgent); if (gtm4wp_is_safari) { window.addEventListener('pageshow', function(event) { if (event.persisted) { // if Safari loads the page from cache usually by navigating with the back button // it creates issues with product list click tracking // therefore GTM4WP forces the page reload in this browser window.location.reload(); } }); } </script>
I am searching for a way to deactivate this behavior.
Thanks, I’ll try via the app! Might take a while.