Jump to content

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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.