Muhammad Bin Saleem
Muhammad Bin Saleem

Reputation: 11

Can't add shopify image through url

I am having trouble regarding this code:

<!doctype html>
<html>
<head>
<title>{{ page_title }}</title>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="description" content="{{ page_description | escape }}">
<link rel="canonical" href="{{ canonical_url }}">
<link rel="stylesheet" href="{{ 'some.css' | asset_url }}" type="text/css">

<meta name="viewport" content="width=device-width,initial-scale=1,shrink-to-fit=no">
{{ content_for_header }} <!-- Header hook for plugins -->
{{ 'bootstrap.min.css' | asset_url | stylesheet_tag }}

</head>
<body>
{% section 'header'%}
<img src="{{section.settings.image | img_url}}" alt="">
<main role="main">
{{ content_for_layout }}
</main>
{{ 'bootstrap.min.js' | asset_url | script_tag }}
{{'https://cdn.shopify.com/s/files/1/0585/4674/9577/files/Untitled-1.jpg?v=1655109717' | 
img_url: '150x'| image_tag'}}

</body>
</html>

The error for image is this:

Liquid error: input to image_tag must be an image_url

Upvotes: 0

Views: 2066

Answers (1)

Rado
Rado

Reputation: 739

As written in the documentation and in your error you need to provide an image_url filter with width or height in order to use the image_tag HTML filter. Also, the filter img_url is deprecated.

I assume that this image is stored in the Files of the Shopify store, so it would be best to use an img tag with a file_img_url filter.

<img src="{{ 'Untitled-1.jpg' | file_img_url: '150x' }}" alt="Image">

Upvotes: 0

Related Questions