Settings_schema In Shopify — How Do I Get The Data?

- 1 answer

I've created the image field from the settings_schema.json , with the id of header.png.

The upload field appeared in the admin, and I uploaded an image. But I can't find out how to access that image?

When I dump the object with {{ settings | json }}  I can't see the the newly uploaded image., or any data that wasn't predefined in the json file (which is formatted underneath).

I've consulted the documentation, but it's not telling me when data my not be appearing in the settings object.

My settings_schema.json:

   "name": "General",
   "settings": [{
      "type": "header",
      "content": "Logo Options"
   }, {
      "type": "color",
      "id": "bg_color",
      "label": "Background (example)",
      "default": "#ffffff"
   }, {
      "type": "color",
      "id": "text_color",
      "label": "Text color (example)",
      "default": "#cccccc"
   }, {
      "type": "checkbox",
      "id": "use_logo",
      "label": "Use Custom Logo?"
   }, {
      "type": "image",
      "id": "header.png",
      "label": "Custom Logo",
      "max-width": 940,
      "max-height": 300
   }, {
      "type": "paragraph",
      "content": "Maximum logo dimensions are 940px wide by 300px high.Your uploaded file will be resized to fit within those constraints.Need a full-width banner? Upload an image with a width of 940px, and a height of 300px or less."


You can access the image like regular one from the /assets folder by this snippet:

{{ 'header.png' | asset_url }}

The images that have been uploaded by image field are stored in the /assets folder in the theme with the same name as the field id from settings_schema.json file.

They are not exist in the settings object, because their id is the file name of the image and it's not a identificator.

PS: You don't have the ability to check if the image exist. For that reason you will have to create additional checkbox field to create show/hide functionality if you need it.