Return to v2.5.0 docs


View Helpers Asset Functions string controller

Returns an img tag. If the image is stored in the local images folder, the tag will also set the width, height, and alt attributes for you. You can pass any additional arguments (e.g. class, rel, id), and the generated tag will also include those values as HTML attributes.

Name Type Required Default Description
source string Yes The file name of the image if it's available in the local file system (i.e. ColdFusion will be able to access it). Provide the full URL if the image is on a remote server.
onlyPath boolean No true
host string No
protocol string No
port numeric No 0
encode boolean No true Use this argument to decide whether the output of the function should be encoded in order to prevent Cross Site Scripting (XSS) attacks. Set it to true to encode all relevant output for the specific HTML element in question (e.g. tag content, attribute values, and URLs). For HTML elements that have both tag content and attribute values you can set this argument to attributes to only encode attribute values and not tag content.
required boolean No true
<!--- Outputs an `img` tag for `images/logo.png` --->

<!--- Outputs an `img` tag for `` --->
#imageTag(source="", alt="ColdFusion on Wheels")#

<!--- Outputs an `img` tag with the `class` attribute set --->
#imageTag(source="logo.png", class="logo")#

Related Functions

Asset Functions