These filters build URLs for assets, media files and storefront resources, and transform images on the fly. They complement the URL filters.

Image transformation filters work on an image URL and can be chained:

{{ product.featured_image | image_url | resize: '400x400' | quality: 80 }}

Asset and file URLs

assets_root

Returns the current Liquid filesystem's asset root.

Parameters: no Ruby arguments.

versacommerceasseturl

Builds a shared compatibility asset path.

Parameters: filename as input.

Example: {{ 'option_selection.js' | versacommerce_asset_url }} returns /static_assets/alien/option_selection.js.

cdn_url

Passes through the supplied URL.

Example: {{ url | cdn_url }} returns the same URL.

globalassetpath

Builds the global asset path.

Parameters: filename as input.

Example: {{ 'theme.js' | global_asset_path }} returns /global/theme.js.

appasseturl

Resolves an application-shipped asset.

Parameters: repository public path as input.

Example: {{ '/assets/public.css' | app_asset_url }} returns the application asset URL.

staticassetspath

Builds a static asset path with a version when available.

Parameters: relative path as input.

Example: {{ 'missing_image.svg' | static_assets_path }} returns /static_assets/missing_image.svg, optionally with a ?v= timestamp.

staticassetsurl

Alias for staticassetspath.

Parameters: relative path as input.

Example: {{ 'missing_image.svg' | static_assets_url }} returns the static asset path.

asset_path

Resolves a theme asset; asset_url is its alias.

Parameters: filename as input.

Example: {{ 'theme.css' | asset_path }} returns the theme asset URL.

dynamiccdnurl

Resolves a sharded CDN URL.

Parameters: optional CDN count, default 4.

Example: {{ url | dynamic_cdn_url }} returns the CDN URL.

mediaimagepath

Builds the shop's uploaded-image URL.

Parameters: filename as input.

Example: {{ 'logo.png' | media_image_path }} returns //<asset-host>/<shop>/mediafiles/images/logo.png.

mediaimageurl

Alias for mediaimagepath.

Parameters: filename as input.

Example: {{ 'logo.png' | media_image_url }} returns the uploaded-image URL.

mediamoviepath

Builds the uploaded-video URL.

Parameters: filename as input.

Example: {{ 'demo.mp4' | media_movie_path }} returns //<asset-host>/<shop>/mediafiles/videos/demo.mp4.

mediamovieurl

Alias for mediamoviepath.

Parameters: filename as input.

Example: {{ 'demo.mp4' | media_movie_url }} returns the uploaded-video URL.

mediadocumentpath

Builds the uploaded-document URL.

Parameters: filename as input.

Example: {{ 'guide.pdf' | media_document_path }} returns //<asset-host>/<shop>/mediafiles/documents/guide.pdf.

mediadocumenturl

Alias for mediadocumentpath.

Parameters: filename as input.

Example: {{ 'guide.pdf' | media_document_url }} returns the uploaded-document URL.

Resource URLs

url_for

Resolves the URL for a tag.

Parameters: tag as input.

Example: {{ tag | url_for }} returns the tag URL.

urlforvariant

Resolves a variant URL from its handle.

Parameters: variant handle as input.

Example: {{ variant.handle | url_for_variant }} returns the variant URL.

articleimgurl

Article-oriented alias for img_url.

Parameters: size or image options.

Example: {{ article | article_img_url: 'medium' }} returns the resized image URL.

blogimgurl

Blog-oriented alias for img_url.

Parameters: size or image options.

Example: {{ blog | blog_img_url: 'medium' }} returns the resized image URL.

pageimgurl

Page-oriented alias for img_url.

Parameters: size or image options.

Example: {{ page | page_img_url: 'medium' }} returns the resized image URL.

lineitemimg_url

Line-item-oriented alias for img_url.

Parameters: size or image options.

Example: {{ item | line_item_img_url: 'medium' }} returns the resized image URL.

gravatar_url

Builds a Gravatar URL.

Parameters: email as input, optional options.

Example: {{ customer.email | gravatar_url }} returns the Gravatar URL.

additional_params

Merges query parameters into a URL.

Parameters: parameter hash.

Example: {{ '/search' | additional_params: q: 'coat' }} returns /search?q=coat.

prependurlparam

Prepends a URL parameter.

Parameters: parameter, optional value.

Example: {{ url | prepend_url_param: 'width', 100 }} returns the URL with the parameter prepended.

Builds a customer registration link.

Parameters: link label as input.

Example: {{ 'Register' | customer_register_link }} returns the registration anchor.

Builds a customer logout link.

Parameters: link label as input.

Example: {{ 'Log out' | customer_logout_link }} returns the logout anchor.

Image transformations

resize

Sets an image resize transformation.

Parameters: resize string.

Example: {{ url | resize: '200x200' }} returns the transformed URL.

canvas

Sets an image canvas transformation.

Parameters: canvas string.

Example: {{ url | canvas: '0' }} returns the transformed URL.

cropmode

Sets image crop mode.

Parameters: mode.

Example: {{ url | cropmode: mode }} returns the transformed URL.

smartcrop

Sets smart-crop transformation.

Parameters: smart-crop string.

Example: {{ url | smartcrop: crop }} returns the transformed URL.

blur

Sets image blur.

Parameters: blur value.

Example: {{ url | blur: '5' }} returns the transformed URL.

quality

Sets image quality.

Parameters: quality value.

Example: {{ url | quality: '80' }} returns the transformed URL.

progressive

Requests progressive image output.

Example: {{ url | progressive }} returns the transformed URL.

background

Sets an image background.

Parameters: background color.

Example: {{ url | background: 'ffffff' }} returns the transformed URL.

convert_to

Requests an image output format.

Parameters: format.

Example: {{ url | convert_to: 'png' }} returns the transformed URL.

refit

Sets the refit transformation.

Parameters: refit value.

Example: {{ url | refit: value }} returns the transformed URL.

gravity

Sets image positioning gravity.

Parameters: gravity value.

Example: {{ url | gravity: value }} returns the transformed URL.

scale

Sets image scale.

Parameters: scale value.

Example: {{ url | scale: 2 }} returns the transformed URL.

imagemaxsize

Reads the maximum image size.

Parameters: no Ruby arguments.

resize_param

Resolves named or explicit image dimensions.

Parameters: size as input.

Example: {{ 'medium' | resize_param }} returns the resize parameter.

Host and scheme

servefromhost

Resolves a URL against the storefront host.

Example: {{ '/cart' | serve_from_host }} returns the storefront URL.

forcehttpscheme

Forces the HTTP URL scheme.

Example: {{ url | force_http_scheme }} returns the URL with the http scheme.

forcehttpsscheme

Forces the HTTPS URL scheme.

Example: {{ url | force_https_scheme }} returns the URL with the https scheme.

force_scheme

Uses a supplied URL scheme.

Parameters: scheme.

Example: {{ url | force_scheme: 'https' }} returns the URL with the given scheme.