Jump to content

getimagesize slow?


karimali831

Recommended Posts

Hello!

 

It took a while to find out why one of my pages is slow.. it is because of getimagesize()

when users link their avatar to a URL and the URL no longer exist, I use getimagesize() function.

 

Is there something else I can to check for a file existent? It must be for any website.

 

Thanks!

Link to comment
https://forums.phpfreaks.com/topic/239941-getimagesize-slow/
Share on other sites

You can do a HEAD request and check the return status.

But whatever method you use, if you're checking on every page load then it will be slow. The only way to speed up the process would be to cache the result, but then it won't always be up-to-date.

 

How about storing the image instead of linking to it?

Link to comment
https://forums.phpfreaks.com/topic/239941-getimagesize-slow/#findComment-1232538
Share on other sites

There's are distinct advantages to storing the images on the server instead of always linking offsite: besides the issue of efficiency, it's more secure. There's always the chance that somebody could write some script on a server that sends one image to certain people (administrators,  moderators, etc.) while sending a different image to other people (people they don't like, people they do like (eight equals equals oh tilde and such), etc.)

The short version is that you always remain in control of what shows up on your site.

 

What aren't you sure about?

Link to comment
https://forums.phpfreaks.com/topic/239941-getimagesize-slow/#findComment-1232541
Share on other sites

There's are distinct advantages to storing the images on the server instead of always linking offsite: besides the issue of efficiency, it's more secure. There's always the chance that somebody could write some script on a server that sends one image to certain people (administrators,  moderators, etc.) while sending a different image to other people (people they don't like, people they do like (eight equals equals oh tilde and such), etc.)

The short version is that you always remain in control of what shows up on your site.

 

What aren't you sure about?

 

I have hundreds with off site URLs with many of the links no longer exist so it looks really messy when I specifying an img tag with invalid source.

Link to comment
https://forums.phpfreaks.com/topic/239941-getimagesize-slow/#findComment-1232569
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.