0

On my Shopify website, I have a list of collection images that are taken depending on what image is uploaded to the collection. I want to override the images and replace them with icons instead. Below is the code when I inspect the element.

<img class="lazyautosizes lazyloaded" src(unknown) data-aspectratio="1.4998556165174703" data-srcset="//cdn.shopify.com/s/files/1/0667/7446/6774/collections/Image_a8a74781-cf71-4613-891f-531d748b822e_720x.jpg?v=1661077157 720w, //cdn.shopify.com/s/files/1/0667/7446/6774/collections/Image_a8a74781-cf71-4613-891f-531d748b822e_900x.jpg?v=1661077157 900w, //cdn.shopify.com/s/files/1/0667/7446/6774/collections/Image_a8a74781-cf71-4613-891f-531d748b822e_1080x.jpg?v=1661077157 1080w" sizes="116px" srcset="SAME LINK AS THAT OF DATA SRCSET"

What I tried in CSS

.lazyautosizes.lazyloaded alt[value= Cell Phones, Smart Watches & Accessories] {background-image: url("https://cdn.shopify.com/s/files/1/0667/7446/6774/files/iphone.png?v=1662374833") !important;

}

Result: Failed to work. The srcset is where the link should be replaced.

UPDATE: I added the following code to my theme.liquid file

    <script>
  <img class="lazyautosizes lazyloaded" src(unknown) data-aspectratio="1.4998556165174703" data-widths="[720, 900, 1080]" data-sizes="auto"
  alt="Cell Phones, Smart Watches & Accessories" data-srcset="//cdn.shopify.com/s/files/1/0667/7446/6774/collections/Image_a8a74781-cf71-4613-891f-531d748b822e_720x.jpg?v=1661077157 720w, //cdn.shopify.com/s/files/1/0667/7446/6774/collections/Image_a8a74781-cf71-4613-891f-531d748b822e_900x.jpg?v=1661077157 900w, //cdn.shopify.com/s/files/1/0667/7446/6774/collections/Image_a8a74781-cf71-4613-891f-531d748b822e_1080x.jpg?v=1661077157 1080w" 
  sizes="116px" srcset="https://cdn.shopify.com/s/files/1/0667/7446/6774/files/smartphone.png?v=1662378908">
  
</script>

Still not working. What am I missing?

2
  • that's not how html and css work, stackoverflow.com/questions/36565685/… Commented Sep 5, 2022 at 11:54
  • I added the following to my theme.liquid file Commented Sep 5, 2022 at 12:20

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.