Scraping image sizes for different screen sizes

I’m writing a script that let’s me know how many images on my website are too big for various screen sizes (eg you have a 500×500 image that may render as 100×100 on mobile). At present it works as a (temporary) JS script that I run and it AJAX’s the information to the database for me to reference when optimising the images later.

My issue is this isn’t very effective because the website has 100s of pages and I’d quite like to automate it rather than manually running the script on all the 100s of pages, each on various screen sizes. I did consider a script that I put a list of URLs into and it cycles through all 100 pages via form of a redirect after each script has run, but this doesn’t seem very time efficient so would like to automate it in way of a server-side php script. But I can’t think/don’t know of a way that I can get the render size of an image (not the actual size) using a php scrape of a page.

Anyone got any ideas?

Add Comment
0 Answer(s)

Your Answer

By posting your answer, you agree to the privacy policy and terms of service.