Right now I have some code which executes once the page is loaded like this:
$(window).load(function() {
$('.featuredimage').each(function(){
var img_width = $(this).width();
var img_height = $(this).height();
if (img_height >= img_width){
$(this).addClass("artistthirdtall");
};
if (img_height < img_width){
$(this).addClass("artistthirdwide");
};
});
});
However, there are some big images on the page and there can be a "flicker" as the images get manipulated by Javascript.
Ideally I'd like to run this function on each image as it loads (rather than wait for them all to load).
I looked at this jQuery load event page: https://api.jquery.com/load-event/ and it looks like there are some serious issues with using it for checking if images are loaded? But the example given is essentially exactly what I'm trying to do.
So is it safe to use the example code given or not?
Thanks
PS - I'm a self-taught developer and don't know that much so please forgive me if I've said something stupid.