source_tag
Generates an HTML <source> tag for a given image_url.
By default, width and height attributes are added to the <source> tag based on the dimensions and aspect ratio from the image URL. However, you can override these attributes with the width and height parameters. If only one parameter is provided, then only that attribute is added.
Params
image_url{String}image_url helper[hash.width]{Number}Specify thewidthattribute of the<source>tag. You can set the parameter to null to prevent the attribute from being added.[hash.height]{Number}Specify theheightattribute of the<source>tag. You can set the parameter to null to prevent the attribute from being added.[hash.sizes]{String}Specify source sizes with the HTML sizes attribute.[hash.widths]{String}Specify source sizes with the HTML sizes attribute.[hash.srcset]{String}By default, Shopline generates asrcset. However, you can create your ownsrcset. Thesrcsetparameter takes precedence over the width parameter. You shouldn't to use thesrcsetparameter unless you want to remove the attribute by setting the parameter to null.[HTML attributes]{String}You can specify HTML sizes attribute by adding a parameter that matches the attribute name, and the desired value.returns{String}<source>tag
Usage
{{ source_tag (image_url object) }}
Example
<picture>
{{ source_tag (image_url image) }}
<img src="default.png">
</picture>
Was this article helpful to you?