Feed Syntax: Media Methods

RO provides custom methods for calling media URLs to send through the feed.

media_url

There are two methods to fetch media URLs: media_url and media_urls. As you can likely guess, the difference between them is that media_url returns a single URL while media_urls returns all URLs specified by the parameters.

The media_url method should follow the format below. For a list of format codes, refer to the Available Media Formats section below:

sku.media_url('format code', 'image tags')

To grab the media URL for an image tagged with "hero" and render it as a 800x800 jpeg, you would enter:

sku.media_url('jpeg-800x800', 'hero')

media_urls

If the channel's feed requires all media URLs passed through the same field, you would use the media_urls method here.

The media_urls method should follow the format below:

sku.media_urls('format code', number of media URLs desired, 'media tags')

To grab 4 media URLs with various tags and render them as 600x300 png images, you would enter:

sku.media_urls('png-600x300', 4, 'hero, front, back, side')

Optional: Base URL Override Parameter

There is an optional parameter that you can use to override the default base URL for the media URLs. This parameter would go after the image tags:

sku.media_urls('format code', number of image URLs desired, 'image tags', 'domain')

Using the example above, we'll grab 4 image URLs with various tags and render them as 600x300 png images. We'll also change the base URL to 'www.yourstore.com/media':

sku.media_urls('png-600x300', 4, 'hero, front, back, side', 'http://www.yourstore.com/media')

Media from SKU vs. SKU Group vs. Family

You have the option to grab media URLs from three different pools: SKU, SKU group, or family.

sku.media_url('jpeg-800x800', 'hero')
sku_group.media_url('jpeg-800x800', 'hero')
family.media_url('jpeg-800x800', 'hero')

Each of these evaluates a different pool of images before providing a media URL. This may result in different media URLs being output.

In the first example, only images associated with the given SKU are evaluated. The media URL for the 'hero' image associated with that SKU is output.

In the third example, all images in the product family for a SKU are evaluated. If there are multiple images with 'hero' tags, only the first image's URL is output.

In the second example, all images within a SKU group are evaluated. SKU groups are more granular groups within a product family that you can define based on a set of common attributes. All SKUs within a product family that have the same values for the specified attributes will be in the same SKU group. In this example, all the images associated with the SKUs in the SKU group will be evaluated; the URL for the first image with a 'hero' tag will be output. To configure SKU groups, please contact RetailOps Support.

Available Media Formats

The table below provides a list of available media formats and their dimensions.

Format ID
Format Code
1
jpeg-original
2
jpeg-200x300
3
jpeg-500x500
4
jpeg-100x100
5
jpeg-90x90
6
jpeg-600x600
7
jpeg-40x40
8
jpeg-800x800
9
jpeg-150x150
10
jpeg-fixed90x90
11
jpeg-fixed100x100
12
jpeg-fixed500x500
13
jpeg-fixed800x800
14
jpeg-fixed1000x1000
15
jpeg-fixed250x250
16
jpeg-fixed200x200
17
png-original
18
jpeg-1024x1024
19
jpeg-fixed40x40
20
png-600x300
21
png-800x400
22
png-1200x600
23
png-200x100
24
jpeg-1200x1200
25
jpeg-fixed1200x1200

Unfixed vs. Fixed Dimensions

Note that media may be rendered in unfixed or fixed dimensions. Media formats 10-16, 19, and 25 all have fixed dimensions; all others are unfixed.

For unfixed media formats, the dimensions specified are the max dimensions for the image. However, the image won't necessarily be rendered in those exact dimensions. RO will take the original image and shrink it down (maintaining the correct aspect ratio to prevent warping) until both dimensions are at or under the max dimensions.

By contrast, for fixed media formats, the dimensions specified will be the exact dimensions of the image. RO will take the original image and shrink it down (again, maintaining the correct aspect ratio) until both dimensions are at or under the max dimensions. Then whitespace will be added around the image so that it meets the exact dimensions specified.

In the example below, the original image has dimensions of 1500x996. Using the jpeg-500x500 format, this would output an image at 500x332. Using the jpeg-fixed500x500 format, this image is still shrunken to 500x332. But then whitespace is added to bring the width from 332 to 500 pixels, outputting an image at 500x500.

Unfixed sample: jpeg-500x500 format

Unfixed sample: jpeg-500x500 format

Fixed sample: jpeg-fixed500x500 format

Fixed sample: jpeg-fixed500x500 format
Have more questions? Submit a request

2 Comments

  • 0
    Avatar
    Jason

    Really great article Quan! Thanks for writing this, as I'm sure it was not a quick project.

  • 0
    Avatar
    Quan Vu

    Thanks Jason! Glad it was helpful for you.

Please sign in to leave a comment.
Powered by Zendesk