Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
Thread: is URL an image?
08-13-2008, 10:35 AM #1
- Join Date
- Mar 2006
- Thanked 0 Times in 0 Posts
is URL an image?
How can i find out if a URL is an image?
ok say i have a link submitted and it is a direct link (yes a hot link!) to an image how can i find this out as the url is not always ending in .jpg or .jpeg or someother image ext.
some links that i know are ok are like this...
but if a url is..
then my script can not work this out. and create a thumb nail from the image for my home page, i have to manually check each one and set it if it is an image. if not an image then it does not show any thumbnail.
is there another way to test?
thanks in advance for your help.
08-13-2008, 11:02 AM #2
Have a look at the parse_url function - that should help you
For example, the following code prints "jpg":
$url = "http://www.mydomain.com/page.jpg?x=0&y=1";
echo pathinfo(parse_url($url, PHP_URL_PATH), PATHINFO_EXTENSION)."\n";
I hope that helps!
Last edited by mlse; 08-13-2008 at 11:11 AM.