|
-
Sep 25th, 2007, 02:50 PM
#1
Thread Starter
Hyperactive Member
IF image has loaded?
I'd like to know the correct function/method to find out if an image has succesfully loaded on my website. So for instance if it hasn't loaded I want to show a standard image.
Thanks
-
Sep 26th, 2007, 04:53 PM
#2
Re: IF image has loaded?
this is not possible with php (from what i know). I looked at the GD library on php.net, and didnt find any function for it. You might want to have a look yourself though.
My usual boring signature: Something
-
Sep 27th, 2007, 04:42 PM
#3
Thread Starter
Hyperactive Member
Re: IF image has loaded?
Wow I cant believe PHP doesnt have a function to support this! Are there are any other methods I can use to show a sample image if an image url doesnt load correctly on my site as otherwise there is just a huge white space!?
-
Sep 27th, 2007, 04:50 PM
#4
Re: IF image has loaded?
well you can check to see if the file exists, and if it doesnt then show another image...
PHP Code:
$file = "img.png";
if(file_exists($file)) {
echo "<img src='$file'>";
} else {
echo "<img src='noimage.png'>";
}
My usual boring signature: Something
-
Sep 29th, 2007, 07:18 AM
#5
Re: IF image has loaded?
Use the file_exists method to check if it exists on the server side. If it is guaranteed to then checking whether or not it loads properly is a purely client-side operation and PHP cannot help further.
You can use the HTML <object> element to display an image with elements nested within as fallbacks. However, this is not very well supported by most browsers.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|