Out now! Check out the Poll results: Do you have a Shopify store?
Our Partner & Developer boards on the community are moving to a brand new home: the .dev community forums! While you can still access past discussions here, for all your future app and storefront building questions, head over to the new forums.

Polaris Image rendering problem

Solved

Polaris Image rendering problem

HunkyBill
Shopify Partner
4853 60 568

With Chrome my code renders an image just fine using the Shopify suggested code for accessing images.

    const images = require.context('../images', true)
    const imagePath = (name) => images(name, true)

    <img src={ imagePath('./logo.png') } className = "object-center object-contain h-48 w-full p-2" />   // render an image in DOM

If I examine the image address is comes across as:

    <mydomain>/packs/media/images/logo-52b3521f113a0775455187c787456a3b.png

Any hey, that address renders the image just fine... so it is a correct URI to the image. Yet Safari refuses to render the image? Say what?

But Safari renders just an image placeholder? What? I am frustrated by this. Why is this a thing? The console has no errors from Safari, but it seems to choke on rendering images. What am I doing wrong here?

Custom Shopify Apps built just for you! hunkybill@gmail.com http://www.resistorsoftware.com
Accepted Solution (1)

HunkyBill
Shopify Partner
4853 60 568

This is an accepted solution.

turns out it was a faulty image, and while Chrome and FF rendered it, Safari has internal guts that prevent it from rendering PNG files with slightly different characteristics. Moving on...

Custom Shopify Apps built just for you! hunkybill@gmail.com http://www.resistorsoftware.com

View solution in original post

Replies 2 (2)

HunkyBill
Shopify Partner
4853 60 568

I changed my code to the following. Chrome and Firefox worked.   

    import Logo from "../images/logo.png";

And in my React App component

 

    <img src={Logo} className="object-center object-contain h-48 w-full p-2"/>

 

So that worked fine.. but not in Safari? What gives with images and Safari. This is a Rails 6 project using Shopify App gem. Nothing crazy. All my images from Shopify render fine.

Custom Shopify Apps built just for you! hunkybill@gmail.com http://www.resistorsoftware.com

HunkyBill
Shopify Partner
4853 60 568

This is an accepted solution.

turns out it was a faulty image, and while Chrome and FF rendered it, Safari has internal guts that prevent it from rendering PNG files with slightly different characteristics. Moving on...

Custom Shopify Apps built just for you! hunkybill@gmail.com http://www.resistorsoftware.com