<cffunction
name="ImageWriteToBrowserCustom"
access="public"
returntype="void"
output="true"
hint="Writes the image to the browser with additional attributes.">
<cfargument
name="Image"
type="any"
required="true"
hint="The ColdFusion image object that you are writing to browser."
/>
<cfargument
name="Alt"
type="string"
required="false"
default=""
hint="The ALT attribute value to apply to the image."
/>
<cfargument
name="Class"
type="string"
required="false"
default=""
hint="The CSS class to apply to the image."
/>
<cfargument
name="Style"
type="string"
required="false"
default=""
hint="The STYLE attribute value to apply to the image."
/>
<cfargument
name="Height"
type="string"
required="false"
default=""
hint="The HEIGHT attribute value to apply to the image."
/>
<cfargument
name="Width"
type="string"
required="false"
default=""
hint="The WIDTH attribute value to apply to the image."
/>
<cfargument
name="Border"
type="string"
required="false"
default=""
hint="The BORDER attribute value to apply to the image."
/>
<cfset var LOCAL = {} />
<cfsavecontent variable="LOCAL.Output">
<cfoutput>
<cfimage
action="writetobrowser"
source="#ARGUMENTS.Image#"
/>
</cfoutput>
</cfsavecontent>
<cfset LOCAL.Output = LOCAL.Output.ReplaceAll(
"(?i) (alt|class|style|height|width|border)=""[^""]*""",
""
) />
<cfset LOCAL.Output = LOCAL.Output.ReplaceFirst(
"\s*/?>\s*$",
""
) />
<cfloop
index="LOCAL.Key"
list="alt,class,style,height,width,border"
delimiters=",">
<cfif Len( ARGUMENTS[ LOCAL.Key ] )>
<cfset LOCAL.Output &= (
" " &
LOCAL.Key &
"=""" &
ARGUMENTS[ LOCAL.Key ] &
""""
) />
</cfif>
</cfloop>
<cfset WriteOutput( LOCAL.Output & " />" ) />
<cfreturn />
</cffunction>