Image Templating with Javascript

The Image field allows content writers to upload an image that can be configured with size constraints and responsive image views.

Retrieve the image url

The easiest way to integrate an image is to retrieve and add the image url to image elements.


Get an image view

It's easy to get the url for an image and any of its views. The following shows how to retrieve the image url for the main view as well as its tablet and mobile views.

const image =

image.url // main image
image.tablet.url // tablet // mobile

Get the image Alt Text

If you added an alt text value to your image, you retrieve and apply it as shown below.

const image =

image.url // url
image.alt // alt

The following shows how to retrieve the alt text for a responsive image view. Note that the alt text will be the same for all views.

const mobileView =

mobileView.url // mobile image url
mobileView.alt // mobile image alt

Get the image Width & Height

Here’s how to retrieve the main image’s width or height.

const image =

image.dimensions.width // image width
image.dimensions.height // image height

Here is how to retrieve the width and height for a responsive image view.

const mobileImage =;

mobileImage.dimensions.width // mobile image width
mobileImage.dimensions.height // mobile image height