Images loaded callback?
When using cloudinary-core-shrinkwrap to auto serve up responsive images, is there an 'images loaded' callback I can hook into?
The reason I ask is that there is a short delay before the images are displayed in the browser, so it would be nice to fade them in once they are loaded.
-
Hi Shirly, I wonder if you can expand on that?
I'm not using React, just a simple flat-file HTML site with cloudinary-core-shrinkwrap. Our image URLs look something like this: https://res.cloudinary.com/[my-company]/image/upload/w_auto,c_scale,f_auto,q_auto/v1553269357/my-image.jpg
If some kind of event were triggered when an image is loaded/ready, that I could hook into, then I would be able to manipulate the images accordingly...
-
Hi Matt,
Are you following the direction to build a responsive URL as described here?
You should get a different width by the size of the device.
Thanks,
Shirly
-
Hi Shirly, thanks for the reply. However, the question I'm asking is a different one.
When Cloudinary 'returns' the scaled/responsive images, there is a short delay before the image is displayed (presumably while the JavaScript and the server decide what size image to send).
It would be hugely useful if the cloudinary-core-shrinkwrap library had an 'images loaded' JavaScript callback that I could hook into. That way I could fade images in gracefully when they're ready, rather than just have them 'pop' into view like they currently do, which is a bit jarring. It's only a few milliseconds delay, but it's enough to notice...
-
Hi Matt,
Thank you for pointing it out. Having the ability to target the loading event makes a lot of sense. I've opened an internal ticket to our developers to consider that (and also consider implementing graceful loading ourselves).
We'll update here if and when there'll be any updates. -
Awesome, thank you. I plan to have another look at this myself anyway soon, so if I figure out a way to do it I'll post it here.
Currently my workaround is to fade the whole page in after 500ms (it's this site if you're interested). This is good enough to mask most of the images 'popping in' as they are displayed, unless your connection speed is very slow. It's not a very 'intelligent' method though - I would prefer to be able to 'lazy load' individual images though when they're ready.
Post is closed for comments.
Comments
16 comments