content_image_uri

content_image_uri is an Aurora template function that can be used to embed dynamic content images into templates.

This article describes what this function does and how to use it.

Introduction

Similar to product_image_uri, the content_image_uri function provides the ability to transform and cache a content image to optimise performance. An image version is also applied to the URL generated, in order to clear the image from cache, therefore always showing the latest image version.

To avoid having to recode your templates, if you move from one image library to another, we recommend the use of content_image_uri. If new image libraries are integrated with Aurora, these can also be made available through this function, and remove the need for template changes.

The content_image_uri function can also be used on blogs and snippets. Be sure to check the Enable Smarty checkbox where required.

Currently, this function accepts the following image formats: JPG, PNG or GIF

Parameters

ParameterExampleRequiredExplanation
width100NThe width of the image. When not informed, it will be the current image width.
height100NThe height of the image. When not informed, it will be the current image height.
filebanners/
homepage.jpg
YThe full path for the image inside a domains _images folder. By default, the image path will use the domain the user is visiting.

For example: Using the example (file="__banners/homepage.jpg") with a user visiting visitdomain.co.uk, the image will be taken from the directory:
templates/visitdomain.co.uk/
_images/banners/homepage.jpg


Images must be stored within a sub folder of the _images folder, if they are to be used with the content_image_uri function.

When using the file parameter, it is recommended that the accompany value is supplied within "". Failure to do so may produce unexpected results. Example use:

file="banners/homepage.jpg"
templates_diranotherdomain.co.ukNAn alternative domain to be used when the image resides in a particular domain, but not all of them.

For example: Using the example (file = banners/homepage.jpg templates_dir=anotherdomain.co.uk__) with a user visiting visitdomain.co.uk, the image will be taken from the directory:
templates/anotherdomain.co.uk/
_images/banners/homepage.jpg
.

This will be ignored when the new Image Transformation service is enabled.
typeresizeandpadNThe image transformation type that Aurora will use to resize an image. This is only applicable to Aurora.

For further information, and examples of usage, regarding the available transformation types for content-image_uri and product_image_uri, please see Image URI Transformation Types
hostdomain.co.ukNIf you are linking to an image via an email or affiliate feed, you will need to include this
resource_url_prefixhttp://cdn.auroracommerce.comNThis allows the entire root URL to be specified.

This is usually set to the $resource_url_prefix variable, which is managed internally by Aurora for you.

Aurora now only supports access over HTTPS and so as a result this method will now always return HTTPS URLs for the images requested of it.

Example Usage

The below examples assume that the user is visiting the domain: visitdomain.co.uk.

 

Using the Original Image

This is an example that can be used when you want to return the original image. 

Use the original picture

{content_image_uri file="banners/homepage.jpg"}

The result is a URL where the image returned is from the folder templates/visitdomain.co.uk/_images/banners/homepage.jpg, whilst keeping the original dimensions. The image will be cached.

 

Resize and Pad an Image

Use this option when you would like to transform the original image.

Resize and Pad a picture

{content_image_uri file="banners/homepage.jpg" width=200 height=200 type=resizeandpad}

The result is a URL with the image returned from the folder templates/visitdomain.co.uk/_images/banners/homepage.jpg, resizing and padding the image with the dimensions: width 200 and height 200. The image will be cached.

 

Resize and Pad an Image, With a Different Domain

Use this option when you would like to transform the original picture, but the image resides inside a particular folder - unique to one domain.

Resize and Pad a picture, using a different domain

{content_image_uri file="banners/homepage.jpg" width=200 height=200 type=resizeandpad templates_dir=anotherdomain.co.uk}

The result is a URL with the image returned from the folder templates/anotherdomain.co.uk/_images/banners/homepage.jpg, resizing and padding the image with the dimensions: width 200 and height 200. The image will be cached.