The following Liquid filters are deprecated and have been replaced. Some themes still use them, but we recommend the alternatives listed below.
Color filters
The following color filters are deprecated:
hextorgba
hex_to_rgba has been replaced by color_to_rgb and color_modify.
Theme settings return hexadecimal values for color settings by default. Use hex_to_rgba to convert the value to RGBA. The default opacity is 1, but you can pass an opacity between 0 and 1. Shorthand hex values like #812 are accepted as well.
.site-footer h1 {
color: {{ settings.color_name }};
}
.site-footer p {
color: {{ settings.color_name | hex_to_rgba: 0.5 }};
}
URL filters
The following URL filters are deprecated:
collectionimgurl
collection_img_url has been replaced by image_url.
Returns the URL of the collection image. Accepts an image size as parameter.
{{ collection.image | collection_img_url: 'medium' }}
//cdn.versacommerce.de/s/files/1/0087/0462/collections/collection-image_medium.png?v=1337103726
img_tag
img_tag has been replaced by image_tag.
Creates an image tag.
{{ 'smirking_gnome.gif' | asset_url | img_tag }}
<img src="//cdn.versacommerce.de/s/files/1/0147/8382/t/15/assets/smirking_gnome.gif?v=1384022871" alt="">
img_tag accepts parameters for the alt text, class names and a size:
- The first parameter is output as alt text.
- The second parameter is the CSS class or classes applied to the tag.
- The last parameter is the image size.
The size parameter of img_tag cannot be combined with the img_url filter. If both are used, img_url takes precedence over the size parameter of img_tag.
{{ 'smirking_gnome.gif' | asset_url | img_tag: 'Smirking gnome', 'css-class-1 css-class-2' }}
<img src="//cdn.versacommerce.de/s/files/1/0147/8382/t/15/assets/smirking_gnome.gif?v=1384022871" alt="Smirking gnome" class="css-class-1 css-class-2">
img_tag can also be applied to these objects:
{{ product | img_tag }}
{{ variant | img_tag: 'alternate text' }}
{{ line_item | img_tag: 'alternate text', 'css-class' }}
{{ image | img_tag: 'alternate text', 'css-class', 'small' }}
{{ collection | img_tag: 'alternate text', 'css-class', 'large' }}
<img src="//cdn.versacommerce.de/s/files/1/0159/3350/products/red_shirt_small.jpg?v=1398706734" alt="Red Shirt Small">
<img src="//cdn.versacommerce.de/s/files/1/0159/3350/products/red_shirt_small.jpg?v=1398706734" alt="alternate text">
<img src="//cdn.versacommerce.de/s/files/1/0159/3350/products/red_shirt_small.jpg?v=1398706734" alt="alternate text" class="css-class">
<img src="//cdn.versacommerce.de/s/files/1/0159/3350/products/red_shirt_small.jpg?v=1398706734" alt="alternate text" class="css-class">
<img src="//cdn.versacommerce.de/s/files/1/0159/3350/products/shirts_collection_large.jpg?v=1338563745" alt="alternate text" class="css-class">
img_url
img_url has been replaced by image_url.
Returns the URL of an image. Accepts size parameters. You can use img_url on these objects:
Pass the image size you need after img_url. If you request a size smaller than the original image, VersaCommerce scales the image for you.
Without a size, the filter returns a small image (100x100).
{{ product | img_url: '100x100' }}
{{ variant | img_url: '720x720' }}
{{ line_item | img_url: '1024x' }}
{{ product | img_url }}
https://cdn.versacommerce.de/s/files/1/1183/1048/products/boat-shoes_100x100.jpeg?v=1459175177
https://cdn.versacommerce.de/s/files/1/1183/1048/products/boat-shoes_720x720.jpeg?v=1459175177
https://cdn.versacommerce.de/s/files/1/1183/1048/products/boat-shoes_1024x.jpeg?v=1459175177
https://cdn.versacommerce.de/s/files/1/1183/1048/products/boat-shoes_small.jpeg?v=1459175177
For line items, img_url returns the URL of the line item's variant image. If the variant has no image, img_url returns the URL of the product image.
You can also use img_url on the image or src attributes of an object.
{{ variant.image | img_url: '300x300' }}
{{ variant.image.src | img_url: '240x' }}
https://cdn.versacommerce.de/s/files/1/0159/3350/products/red_shirt_300x300.jpg?v=1398706734
https://cdn.versacommerce.de/s/files/1/0159/3350/products/red_shirt_240x.jpg?v=1398706734
img_url cannot transform icon files (.ico). If you pass a size or format for an icon file, img_url returns the original file.
{{ settings.favicon | img_url: '300x300' }}
{{ settings.favicon | img_url: '240x', scale: 2, format: 'pjpg' }}
https://cdn.versacommerce.de/s/files/1/0159/3350/files/icon.ico?v=1398706734
https://cdn.versacommerce.de/s/files/1/0159/3350/files/icon.ico?v=1398706734
Size parameters
The size parameters on this page work with these URL filters:
img_url, used in some older themesasset_img_urlfile_img_url
You can pass exact pixel dimensions for the width and height of an image, up to 5760 x 5760 px. The original aspect ratio is kept unless you crop the image.
Whatever size you pass, an image is never larger than its original dimensions.
For example:
{{ product | img_url: '450x450' }}
You can pass only a width or only a height. VersaCommerce then calculates the other dimension from the original image size and keeps the aspect ratio:
{{ product | img_url: '125x' }}
{{ product | img_url: 'x500' }}
To keep the original size, request the master image:
{{ product | img_url: 'master' }}
Pass a crop parameter to make sure the resulting image matches the requested dimensions. If the whole image does not fit, crop defines which part is shown. Valid options:
topcenterbottomleftright
{{ product | img_url: '400x400', crop: 'bottom' }}
Without crop, VersaCommerce uses the largest image that fits the given dimensions, which may not fill the whole space.
The scale parameter sets the pixel density of the image. Valid options:
23
{{ product | img_url: '400x400', scale: 2 }}
The format parameter sets the file format of the image. Valid options:
jpgpjpg
{{ product | img_url: '400x400', format: 'pjpg' }}
pjpg is a progressive JPEG. A browser loads a progressive JPEG at full size with gradually increasing quality, instead of loading it top to bottom in full quality like a regular JPEG.
productimgurl
product_img_url has been replaced by image_url.
Creates the URL of the product image. Accepts an image size as parameter.
{{ product.featured_image | product_img_url: "medium" }}
//cdn.versacommerce.de/s/files/1/0087/0462/products/shirt14_medium.jpeg?v=1309278311
Named size parameters
Named size parameters have been replaced by numeric size parameters.
Instead of a numeric image size you can pass a named size to these URL filters:
img_url, used in some older themesasset_img_urlfile_img_url
| Name | Maximum image size |
|---|---|
| pico | 16 x 16 pixels |
| icon | 32 x 32 pixels |
| thumb | 50 x 50 pixels |
| small | 100 x 100 pixels |
| compact | 160 x 160 pixels |
| medium | 240 x 240 pixels |
| large | 480 x 480 pixels |
| grande | 600 x 600 pixels |
| original | 1024 x 1024 pixels |
Date formats
Date formats are used with some filters, such as time_tag and date.
These format parameters are deprecated:
shortlong
{{ article.published_at | time_tag: format: 'short' }}
<time datetime="2016-02-24T14:47:51Z">February 24, 2016</time>