CFLib.org – Common Function Library Project

isImage(imgURL)

Last updated September 7, 2005

author

Nick Maloney

Version: 1 | Requires: CF6 | Library: UtilityLib

Description:
Takes a url of an image as an argument. Returns boolean value based on whether or not the remote image is a valid jpeg or gif.

Return Values:
Returns a boolean.

Example:

<cfset imgURL = "http://cflib.org/images/logo_top.gif">

<cfif isImage(imgURL)>
	<img src="#imgURL#">
<cfelse>
	NO IMAGE
</cfif>

Parameters:

Name Description Required
imgURL URL. Yes

Full UDF Source:

<!---
 Checks to see if an image URL contains a valid jpeg or gif.
 
 @param imgURL 	 URL. (Required)
 @return Returns a boolean. 
 @author Nick Maloney (nmaloney@prolucid.com) 
 @version 1, September 7, 2005 
--->
<cffunction name="isImage" returntype="boolean" output="false">
	<cfargument name="imgURL" type="string" required="true">
	<cftry>
		<cfhttp method="get" url="#arguments.imgURL#" />
		<cfif cfhttp.mimetype eq "image/jpeg" or cfhttp.mimetype eq "image/gif">
			<cfreturn true>
		<cfelse>
			<cfreturn false>
		</cfif>
	<cfcatch>
		<cfreturn false>
	</cfcatch>
	</cftry>
</cffunction>
blog comments powered by Disqus

Search CFLib.org


Latest Additions

Kevin Cotton added
date2ExcelDate
May 5, 2016

Raymond Camden added
CapFirst
April 25, 2016

Chris Wigginton added
loremIpsum
January 18, 2016

Gary Stanton added
calculateArrival...
November 19, 2015

Sebastiaan Naafs - van Dijk added
getDaysInQuarter
November 13, 2015

Created by Raymond Camden / Design by Justin Johnson