# Deprecated filters

The following Liquid filters are deprecated and have been replaced.

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:

## hex_to_rgba

`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.

```liquid
.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:

## collection_img_url

`collection_img_url` has been replaced by `image_url`.

Returns the URL of the collection image. Accepts an [image size](https://developer.versacommerce.de/articles/liquid-filters-url-filters) as parameter.

```liquid
{{ collection.image | collection_img_url: 'medium' }}
```

```text
//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.

```liquid
{{ '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`.

```liquid
{{ 'smirking_gnome.gif' | asset_url | img_tag: 'Smirking gnome', 'css-class-1 css-class-2' }}
```

```html
<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](https://developer.versacommerce.de/articles/liquid-objects-product)
- [variant](https://developer.versacommerce.de/articles/liquid-objects-variant)
- [line_item](https://developer.versacommerce.de/articles/liquid-objects-lineitem)
- [collection](https://developer.versacommerce.de/articles/liquid-objects-collection)
- [image](https://developer.versacommerce.de/articles/liquid-objects-image)

```liquid
{{ 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' }}
```

```html
<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](#size-parameters). You can use `img_url` on these objects:

- [product](https://developer.versacommerce.de/articles/liquid-objects-product)
- [variant](https://developer.versacommerce.de/articles/liquid-objects-variant)
- [line_item](https://developer.versacommerce.de/articles/liquid-objects-lineitem)
- [collection](https://developer.versacommerce.de/articles/liquid-objects-collection)
- [article](https://developer.versacommerce.de/articles/liquid-objects-article)
- [image](https://developer.versacommerce.de/articles/liquid-objects-image)

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).

```liquid
{{ product | img_url: '100x100' }}
{{ variant | img_url: '720x720' }}
{{ line_item | img_url: '1024x' }}
{{ product | img_url }}
```

```text
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.

```liquid
{{ variant.image | img_url: '300x300' }}
{{ variant.image.src | img_url: '240x' }}
```

```text
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.

```liquid
{{ settings.favicon | img_url: '300x300' }}
{{ settings.favicon | img_url: '240x', scale: 2, format: 'pjpg' }}
```

```text
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 themes
- `asset_img_url`
- `file_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:

```liquid
{{ 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:

```liquid
{{ product | img_url: '125x' }}
```

```liquid
{{ product | img_url: 'x500' }}
```

To keep the original size, request the master image:

```liquid
{{ 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:

- `top`
- `center`
- `bottom`
- `left`
- `right`

```liquid
{{ 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:

- `2`
- `3`

```liquid
{{ product | img_url: '400x400', scale: 2 }}
```

The `format` parameter sets the file format of the image. Valid options:

- `jpg`
- `pjpg`

```liquid
{{ 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.

## product_img_url

`product_img_url` has been replaced by `image_url`.

Creates the URL of the product image. Accepts an [image size](https://developer.versacommerce.de/articles/liquid-filters-url-filters) as parameter.

```liquid
{{ product.featured_image | product_img_url: "medium" }}
```

```text
//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 themes
- `asset_img_url`
- `file_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](https://developer.versacommerce.de/articles/liquid-filters-html-filters#timetag) and [date](https://developer.versacommerce.de/articles/liquid-filters-additional-filters#date).

These `format` parameters are deprecated:

- `short`
- `long`

```liquid
{{ article.published_at | time_tag: format: 'short' }}
```

```html
<time datetime="2016-02-24T14:47:51Z">February 24, 2016</time>
```
