forked from jordanclark/cfwheels-FallbackImage
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFallbackImage.cfc
More file actions
executable file
·40 lines (34 loc) · 1.4 KB
/
FallbackImage.cfc
File metadata and controls
executable file
·40 lines (34 loc) · 1.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
<cfcomponent output="false" mixin="global">
<cfset $initFallbackImage()>
<cffunction name="init">
<cfset this.version = "1.1.5">
<cfreturn this>
</cffunction>
<cffunction name="$initFallbackImage" mixin="controller" hint="Initializes application variables used to generate the required field indicator.">
<cfparam name="application.fallbackImage.environments" type="string" default="design,development,testing,maintenance,production">
</cffunction>
<cffunction name="$imageTag" returntype="string" access="public" output="false">
<cfset var backup = "">
<cfif structKeyExists( arguments, "fallback" ) AND len( arguments.fallback ) AND listFindNoCase( application.fallbackImage.environments, application.wheels.environment )>
<cfset backup = arguments.fallback>
<cfscript>
local.source = listToArray(arguments.source,"/");
if (local.source[1] eq "images") {
arrayDeleteAt(local.source,1);
}
local.source = arrayToList(local.source,"/");
StructUpdate(arguments, "source", local.source);
</cfscript>
<cfset structDelete( arguments, "fallback" )>
<cftry>
<cfreturn core.$imageTag( argumentCollection=arguments )>
<cfcatch>
<cfset arguments.source = backup>
<cfreturn core.$imageTag( argumentCollection=arguments )>
</cfcatch>
</cftry>
<cfelse>
<cfreturn core.$imageTag( argumentCollection=arguments )>
</cfif>
</cffunction>
</cfcomponent>