-
Notifications
You must be signed in to change notification settings - Fork 4.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Cover Block + Featured Image: Lazy Loading attribute is not removed #46789
Comments
@gyurmey2 After testing this myself, I can verify that this happens today, regardless of whether you use a https://core.trac.wordpress.org/ticket/56930 is scheduled to fix at least the first scenario (using The point that you can't remove lazy-loading even with |
Hi @felixarntz, In 6.2-beta2 (latest nightly too), I noticed that the |
@gyurmey2 Thanks for sharing that example! I took a look and found the reason why those bottom images don't have Right now, the To summarize: What you're describing is right now an expected issue, but definitely something that we can fix in the near future. I'll add it to my notes for the remaining issues with lazy-loading that I have been researching. Aiming to get those fixed in WordPress 6.3. |
@felixarntz Thanks for the clarification. And is there any way to enable |
@gyurmey2 A class-based approach doesn't work, but I think there's a way to do it more directly through setting the When using the filter, make sure to only touch the image if I'm hopeful we can improve that experience out of the box for WordPress 6.3 though. |
It's a bit hard for me, so I'll wait for WordPress 6.3. Thank you for your engagement. |
I can confirm that this problem still exists today version 6.2.2 using 2023 theme, cover block image does not respond to any php function trying to target attributes, site wide disabling of lazy load (add_filter( 'wp_lazy_loading_enabled', '__return_false' ); |
Maybe just add an option in the block settings to toggle lazyload on/off. That way the user can define if it should or should not lazy load. Rather than trying to determine if it's the first block, etc. Just seems easier to allow the user to control it via a field or toggle. Default it to on so that by default no one is impacted. |
@webfolkcreative , absolutely what I am saying make it super simple to toggle that baby on and off. I have the feeling that the code for the gutenberg blocks is just a bit too vexing for the WP core to deal with. |
@JustinLindsayChapman Thank you for the feedback. As the changes are only implemented in WordPress 6.3, I would encourage you to please do another test using that release. You can test it in advance of the 6.3 stable release, by using the latest WordPress 6.3 release candidate in a test or development environment: https://wordpress.org/news/2023/08/wordpress-6-3-rc3/ |
@felixarntz No worries, that is how things get better. I will take a look but my time is over allocated at the moment and I probably won't get a chance before the 8th rolls around. Will get back to here if I have some success. |
I addressed this issue by adding custom attributes to the image and cover block that is a boolean "Enable Lazy Loading" with a default to true. If it's set to false I filter the block content output and strip the loading="lazy" attribute. of course there is code setting up the custom attributes and admin interactions but this is the filtering of the content
This way if I start with a cover block i can just toggle that off, and if that is done in a template or page or hero pattern then i'm good. |
Description
The featured image used in the cover block always has the
loading="lazy"
attribute and is not skipped when it's first on the page (although it should be). It can't even be removed by adding the code snippetadd_filter('wp_lazy_loading_enabled', ' __return_false');
Step-by-step reproduction instructions
loading="lazy"
attribute has been removed.Screenshots, screen recording, code snippet
Environment info
Theme: TT3
Gutenberg: 14.8.1, 14.9.20221224 and without.
Please confirm that you have searched existing issues in the repo.
Yes
Please confirm that you have tested with all plugins deactivated except Gutenberg.
Yes
The text was updated successfully, but these errors were encountered: