isImage(imgURL)
Last updated September 08, 2005
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>
Search CFLib.org
Latest Additions
Raymond Camden added
QueryDeleteRows
November 04, 2017
Leigh added
nullPad
May 11, 2016
Raymond Camden added
stripHTML
May 10, 2016
Kevin Cotton added
date2ExcelDate
May 05, 2016
Raymond Camden added
CapFirst
April 25, 2016