β³ π Please allow adding CSS classes to images (not the parent) (Duplicate) #24410
Replies: 4 comments 3 replies
|
Why don't you use
According to their own documentation that feature will be removed soon:
|
|
@m1ga Thank you for the info, I was unaware of JetPack's plans. Have you been able to make the WP solution work with Elementor? My general concern is to set a default to use lazy, but to set it to eager in a few specific cases (especially when using anchor links, which do often do not align correctly when lazy loading above the anchor). I have similarly found that data attributes are not applied as directed, so I'm not sure how one could set loading="eager" on an IMG element (https://make.wordpress.org/core/2020/01/29/lazy-loading-images-in-wordpress-core/). I'm not sure if Elementor would apply this on the IMG or parent DIV and how WP would respond. As for |
|
Thank you for that info. Is there active work on this issue? I see issue
20217 was initially submitted over a year ago.
β¦On Sun, Nov 26, 2023 at 2:54β―PM Michael Gangolf ***@***.***> wrote:
just saying that Elementor does it automatically by looking at the
position
https://github.com/elementor/elementor/blob/d51c409536dbe61146701582d76ec0a736467455/modules/image-loading-optimization/module.php#L228-L230
and you have to somehow override that or perhaps use JS to collect your
images on domready and load them by hand.
The issue with the anchor link is that the target position changes during
scrolling as images are loaded. It's a very common issue
<https://www.google.com/search?q=anchor+link+click+lazy+loading+images+wrong+target+position>
and in the old jquery days you would update the position during scrolling:
https://stackoverflow.com/a/48652859 (not used that in years!).
So as you've said: removing the lazy load part is an option to fix that.
If I remember correctly the scroll part is inside Elementor too. So it
calculates the scroll position for you and is not updating it during
scrolling. This might be the issue to follow #20217
<#20217>
β
Reply to this email directly, view it on GitHub
<#24410 (reply in thread)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/APPMU6X6SJVBS6UHTRCPVRLYGOT73AVCNFSM6AAAAAA726R2ECVHI2DSMVQWIX3LMV43SRDJONRXK43TNFXW4Q3PNVWWK3TUHM3TMNZUGY2TS>
.
You are receiving this because you authored the thread.Message ID:
***@***.***>
|
|
In the backend it is possible to set a class and id on an image. Setting this has no effect. I suggest either:
|
Uh oh!
There was an error while loading. Please reload this page.
Prerequisites
What problem is your feature request going to solve? Please describe.
Please allow us to add CSS classes to directly to the
when posting individual images. This would make it possible to apply styles to images.
The current implementation is for classes to get added to the DIV wrapper for the IMG element. This strikes me as a bug, as I cannot see much practical value to style parents of individual images, but plenty of reasons to style the image. For example, allowing classes on the IMG would let you add the "skip-lazy" class to direct Jetpack to avoid lazy loading a specific image.
This is a known issue: more details at #21799
Describe the solution you'd like
When you set "CSS Classes" for an image widget, it should be applied to the image, not its parent.
Describe alternatives you've considered
no practical workarounds other than to switch to manual code blocks instead of the image widget
Additional context
No response
All reactions