---
title: "image"

doc_type: static
doc_category: static
doc_version: v20260901
source_url:
  html: 'https://developer.shopline.com/docs/handlebars/objects/image'
  md: 'https://developer.shopline.com/docs/handlebars/objects/image.md'
---
# image

<div class="code-flex">

<div>
  <ObjectSummary>
    The image object, such as a collection or product image.
  </ObjectSummary>

  <ObjectDescription>
    Visit the [SHOPLINE Help Center](https://help.shopline.com/hc/zh-cn/articles/900005249963-%E5%B0%86%E6%9C%AC%E5%9C%B0%E5%9B%BE%E7%89%87-%E8%A7%86%E9%A2%91%E7%AD%89%E6%96%87%E4%BB%B6%E4%B8%8A%E4%BC%A0%E8%87%B3%E6%96%87%E4%BB%B6%E5%BA%93) to learn about the image formats supported by SHOPLINE.
  </ObjectDescription>

  > **Tip**
>
> Use the [image_tag](https://developer.shopline.com/docs/handlebars/helpers/media/image-tag.md) and [image_url](https://developer.shopline.com/docs/handlebars/helpers/media/image-url.md) filters to display images on the storefront.

  #### Properties

  <ObjectProperty
    name="alt"
    types={["string"]}
  >
    <ObjectSummary>
      The alt text of the image.
    </ObjectSummary>
  </ObjectProperty>

  <ObjectProperty
    name="aspect_ratio"
    types={["number"]}
  >
    <ObjectSummary>
      The aspect ratio of the image, expressed as a decimal.
    </ObjectSummary>
  </ObjectProperty>
  <ObjectProperty
    name="attached_to_variant?"
    types={["boolean"]}
  >
    <ObjectSummary>
      Returns `true` if the `image` is related with a `variant`. Otherwise, returns `false`.
    </ObjectSummary>
    <ObjectSummary>
    The `attached_to_variant` property only applies to `image` objects accessed through:
      - [product.featured_image](https://developer.shopline.com/docs/handlebars/objects/product.md)
      - [product.images](https://developer.shopline.com/docs/handlebars/objects/product.md)
    </ObjectSummary>
    <ObjectSummary>
    Referencing this property on an `image` from another source will return `null`.
    </ObjectSummary>
  </ObjectProperty>
  <ObjectProperty
    name="height"
    types={["number"]}
  >
    <ObjectSummary>
      The height of the image in pixels.
    </ObjectSummary>
  </ObjectProperty>
  <ObjectProperty
    name="id"
    types={["number"]}
  >
    <ObjectSummary>
      The ID of the image.
    </ObjectSummary>
    <ObjectSummary>
      Referencing the `id` property for the preview image of a `generic_file` or `media` object returns `null`.
    </ObjectSummary>
  </ObjectProperty>
  <ObjectProperty
    name="media_type"
    types={["string"]}
  >
    <ObjectSummary>
      The media type of the image. Always returns `image`.
    </ObjectSummary>
    <ObjectSummary>
      The `media_type` property only applies to images accessed through:
        - product.media
        - file_reference type metafields
    </ObjectSummary>
    <ObjectSummary>
      If this property is referenced on an `image` from another source, it returns `null`.
    </ObjectSummary>
    <ObjectDescription>
      Example
    </ObjectDescription>

    <Admonition title="Filter Specific Types of Image Objects" type="info">
      You can use the [where helper](https://developer.shopline.com/docs/handlebars/helpers/array/where.md) to filter the `media_type` property of [product.media](https://developer.shopline.com/docs/handlebars/objects/product.md) to get all image objects of the desired type.
    </Admonition>

    <Example data={['product.media']} layout="vertical">
      ```handlebars
      {{ assign 'demo_images' (where product.media 'media_type' 'image') }}

      {{#each demo_images as |image|}}
        {{image_tag (image_url image width=400) class="image-demo" }}
      {{/each}}
      ```
    </Example>
  </ObjectProperty>
  <ObjectProperty
    name="position"
    types={["number"]}
  >
    <ObjectSummary>
      The position of the image in the [product.media](https://developer.shopline.com/docs/handlebars/objects/product.md) or [product.images](https://developer.shopline.com/docs/handlebars/objects/product.md) array.
    </ObjectSummary>
    <ObjectSummary>The `position` property only applies to images related to products. Referencing this property on an `image` from another source returns `null`.</ObjectSummary>
  </ObjectProperty>
  <ObjectProperty name="preview_image" types={["image"]}>
    <ObjectSummary>
      The preview image.
    </ObjectSummary>
    <ObjectSummary>
      The `preview_image` property only applies to images accessed through:
        - [product.featured_media](https://developer.shopline.com/docs/handlebars/objects/product.md)
        - [product.media](https://developer.shopline.com/docs/handlebars/objects/product.md)
        - file_reference type metafields
    </ObjectSummary>
    <ObjectSummary>When this property is referenced on an `image` from another source, it returns `null`.</ObjectSummary>
  </ObjectProperty>
  <ObjectProperty name="product_id" types={["number"]}>
    <ObjectSummary>
       The ID of the product related with the image.
    </ObjectSummary>
    <ObjectSummary>
    The `product_id` property only applies to images related to products. If this property is referenced on an image from another source, it returns `null`.
    </ObjectSummary>
  </ObjectProperty>
  <ObjectProperty name="src" types={["string"]}>
    <ObjectSummary>
      The relative URL of the image.
    </ObjectSummary>
  </ObjectProperty>
  <ObjectProperty name="variants" types={[<Mdx>array of [variant](https://developer.shopline.com/docs/handlebars/objects/variant.md)</Mdx>]}>
    <ObjectSummary>
    The variants related with the `image`.
    </ObjectSummary>
    <ObjectSummary>
    The `variants` property only applies to `image` objects accessed through:
      - [product.featured_image](https://developer.shopline.com/docs/handlebars/objects/product.md)
      - [product.images](https://developer.shopline.com/docs/handlebars/objects/product.md)
    </ObjectSummary>
    <ObjectSummary>
    Referencing this property on an `image` from another source will return `null`.
    </ObjectSummary>
  </ObjectProperty>
  <ObjectProperty name="width" types={["number"]}>
    <ObjectSummary>
      The width of the image in pixels.
    </ObjectSummary>
  </ObjectProperty>
  <br/>
  #### Directly Referencing an Image Object
  <ObjectSummary>
    When an `image` object is directly referenced, the relative URL path of the image is returned.
  </ObjectSummary>

  <Example data={['product.featured_image']} layout="vertical">
    ```handlebars
    {{ product.featured_image.src }}
    ```
  </Example>

</div>

<div>
  <ObjectAccess
    object="image"
    global={false}
    parents={[
      { object: 'article.image', link: '/docsv2/ec20/hdwvcvrgnfcjf4gq/96arp92pnm7h8rk3#image' },
      { object: 'blog.image', link: '/docsv2/ec20/hdwvcvrgnfcjf4gq/ysxb57s3p8z99vpc#image' },
      { object: 'collection.image', link: '/docsv2/ec20/hdwvcvrgnfcjf4gq/bgaerupeyfawz4am#image' },
      /* { object: 'generic_file.preview_image', link: 'handlebars-objects-generic_file' }, */
      { object: 'line_item.image', link: '/docsv2/ec20/hdwvcvrgnfcjf4gq/9y14nnr3jpdahd7s#image' },
      { object: 'media.preview_image', link: '/docsv2/ec20/hdwvcvrgnfcjf4gq/2xdqkxqbz14xcne6#preview_image' },
      /* { object: 'model.preview_image', link: 'handlebars-objects-model' }, */
      { object: 'product.featured_image', link: '/docsv2/ec20/hdwvcvrgnfcjf4gq/tfzgv1cp3z3wzk1s#featured_image' },
      { object: 'product.media', link: '/docsv2/ec20/hdwvcvrgnfcjf4gq/tfzgv1cp3z3wzk1s#media' },
      { object: 'product.images', link: '/docsv2/ec20/hdwvcvrgnfcjf4gq/tfzgv1cp3z3wzk1s#images' },
      { object: 'variant.image', link: '/docsv2/ec20/hdwvcvrgnfcjf4gq/gjjjhvusthxd5ucy#image' },
      { object: 'video.preview_image', link: '/docsv2/ec20/hdwvcvrgnfcjf4gq/8pcdz2fkeqvjxzwa#preview_image' },
      { object: 'collection.featured_image', link: '/docsv2/ec20/hdwvcvrgnfcjf4gq/bgaerupeyfawz4am#featured_image' },
      { object: 'external_video.preview_image', link: 'handlebars-objects-external_video#preview_image' },
      { object: 'image.preview_image', link: '/docsv2/ec20/hdwvcvrgnfcjf4gq/tzn8a4qsc8r1w4ks#preview_image' },
      { object: 'variant.featured_image', link: '/docsv2/ec20/hdwvcvrgnfcjf4gq/gjjjhvusthxd5ucy#featured_image' },
      { object: 'user.image', link: 'handlebars-objects-user#image' },
      { object: 'page_image' },
    ]}
  />
</div>

</div>
