Hi everyone,
I have created a shopify store page using the TASTE theme - www.letsswap.in
I am trying to add background image selector for all sections - its working for all except the product information page. I followed the below process for each of the other sections:
- Added the schema code after “settings”: [ in that section for e.g rich-text.liquid for making this change in rich-text section
{
“type”:“checkbox”,
“id”:“enable-background”,
“label”: “Enable Background Image” },
{ “type”:“image_picker”,
“id”:“enable-background-image”,
“label”: “Select Background Image” },
- Added the CSS code after {%- style -%}
{% if section.settings.enable-background %}
.add-background-{{ section.id }}{
background-image: url({{ section.settings.enable-background-image | img_url: ‘master’ | width: 1440, height: 600 }});
background-size: cover;
background-position: center center;
background-attachment: local; }
{% endif %}
- Under the class for that section, modified the code to include the image selector
Changed this →
To this →
This helped me add background image selector in all sections but for the product detail page, I am not able to add this 3rd part as there are multiple classes being used.
Can someone guide me on how to do this for product page as well? I am trying to add this code in sections/main-product.liquid file
1 Like
1.Add Schema Settings
Open sections/main-product.liquid and add the following inside the “settings”: [ array in the schema at the bottom:
{
"type": "checkbox",
"id": "enable-background",
"label": "Enable Background Image"
},
{
"type": "image_picker",
"id": "enable-background-image",
"label": "Select Background Image"
}
2.Add the CSS for Background
Inside the {% style %} block (or create one at the top of the file if it doesn’t exist), add this:
{% if section.settings.enable-background %}
.add-background-{{ section.id }} {
background-image: url({{ section.settings.enable-background-image | img_url: 'master' | width: 1440, height: 600 }});
background-size: cover;
background-position: center center;
background-attachment: local;
}
{% endif %}
- Wrap the Product Section with the Background Class
Find the outermost that wraps your product details. It might look like this:
Change it to this (you might need to wrap the existing div if no outer wrapper exists):
If the file has multiple layout containers or divs around the product info, try wrapping all of them with this wrapper to apply the background correctly.
2 Likes
Hello @theSWAPlife
Thank you for your response. It’s good to know that it’s worked for you. Kindly feel free to get back to me if you need any further assistance. If helpful, please like all posts.
1 Like