---
title: "image"

doc_type: static
doc_category: static
doc_version: v20270301
source_url:
  html: 'https://developer.shopline.com/docs/sline/object/image'
  md: 'https://developer.shopline.com/docs/sline/object/image.md'
---

# image


    An image, such as an image of a product or collection.

    For more information about the image formats supported by SHOPLINE, visit [Help Center](https://help.shopline.com/hc/en-001/articles/4406422263577-Guide-to-Image-Size).



    <div>
    
## Properties

        
<ObjectProperty 
    name="alt"
    types={[<Mdx>string</Mdx>]}
>
<ObjectSummary>
The alternative text for the image, displayed when the image fails to load.


</ObjectSummary>
</ObjectProperty>
        
<ObjectProperty 
    name="aspect_ratio"
    types={[<Mdx>float</Mdx>]}
>
<ObjectSummary>
The aspect ratio of the image as a decimal.


</ObjectSummary>
</ObjectProperty>
        
<ObjectProperty 
    name="attached_to_variant"
    types={[<Mdx>boolean</Mdx>]}
>
<ObjectSummary>
Whether the image is associated with a variant.

- `true`: The image is associated with a variant.
- `false`: The image is not associated with any variant.
</ObjectSummary>
</ObjectProperty>
        
<ObjectProperty 
    name="height"
    types={[<Mdx>integer</Mdx>]}
>
<ObjectSummary>
The height of the image in pixels.


</ObjectSummary>
</ObjectProperty>
        
<ObjectProperty 
    name="id"
    types={[<Mdx>string</Mdx>]}
>
<ObjectSummary>
The unique identifier for the image.

If you reference the `id` property of the preview image of a `generic_file` or `media` object, `nil` is returned.
</ObjectSummary>
</ObjectProperty>
        
<ObjectProperty 
    name="media_type"
    types={[<Mdx>string</Mdx>]}
>
<ObjectSummary>
The media type. The value is fixed to `image`, indicating an image.


</ObjectSummary>
</ObjectProperty>
        
<ObjectProperty 
    name="position"
    types={[<Mdx>integer</Mdx>]}
>
<ObjectSummary>
The position number of the image in the `product.images` or `product.media` array.


</ObjectSummary>
</ObjectProperty>
        
<ObjectProperty 
    name="preview_image"
    types={[<Mdx>[image](https://developer.shopline.com/docs/sline/object/image.md)</Mdx>]}
>
<ObjectSummary>
The preview image of the image.

This property is only available for images accessed through the following sources:

- [product.featured_media](https://developer.shopline.com/docs/sline/object/product.md)
- [product.media](https://developer.shopline.com/docs/sline/object/product.md)

If you reference this property of an image accessed from any other source, `nil` is returned.
</ObjectSummary>
</ObjectProperty>
        
<ObjectProperty 
    name="product_id"
    types={[<Mdx>string</Mdx>]}
>
<ObjectSummary>
The ID of the product associated with the image.

This property is only available for images associated with products. If you reference this property of an image not associated with any product, `nil` is returned.
</ObjectSummary>
</ObjectProperty>
        
<ObjectProperty 
    name="src"
    types={[<Mdx>string</Mdx>]}
>
<ObjectSummary>
The relative URL of the image.


</ObjectSummary>
</ObjectProperty>
        
<ObjectProperty 
    name="width"
    types={[<Mdx>integer</Mdx>]}
>
<ObjectSummary>
The width of the image in pixels.


</ObjectSummary>
</ObjectProperty>
        
    
    </div>


