Ad

How To Make CSS Using Settings.value In Shopify?

- 1 answer

I set a value in settings_data.json of Shopify Config.

And I am trying to insert it into my CSS.

settings_schema.json
...
{
  "type": "image",
  "id": "image1.png"
  "label": "Background Image"
}
...
index.liquid
...
<style>
.div {
 background-color: url({{image1.png}});
}
</style>

But I can't get the background image.

How can I fix?

Ad

Answer

You have to use a filter for the image in order to show the full URL address:

For example: {{ image1.png | img_url: 'medium' }}

Ad
source: stackoverflow.com
Ad