img_tag Filter

Generate an HTML <img> tag.

Parameters

Parameter Required Description
alt No string Alternative text to be used for the <img> tag’s alt attribute.
class No string Any additional parameters are added to the <img> tag as classes listed in the class attribute.

Category

HTML Filters

Description

Generates an HTML image tag.

You’ll typically use this tag in a couple different ways:

  1. Referencing images stored along with your theme, chained with the asset_url filter.

    {{ 'images/logo.png' | asset_url | img_tag: 'Logo' }}
  2. Referencing an image object (or file object containing an image).

    {{ photo | img_tag: photo.title }}