medusajs / medusa

Building blocks for digital commerce
https://medusajs.com
MIT License
25.01k stars 2.5k forks source link

Media Images in Admin Panel not working when saved programmatically (aside from thumbnail) #4957

Open haveamission opened 1 year ago

haveamission commented 1 year ago

Bug report

Describe the bug

Media images in the admin panel do not work correctly - they are stored in the database as such:

{"https://d32vzsop7y1h3k.cloudfront.net/81689ae11956544fb0527cd725b29c60.JPG"}

Which the admin panel is correctly able to parse for the thumbnail image, however for the media images, it seems to be adding the whole thing, including the curly braces and quotes, into the image src string, like so:

<img src="{&quot;https://d32vzsop7y1h3k.cloudfront.net/9e00d4fc3d18380679fd73998204ab0b.JPG&quot;}" alt="Image 1" class="rounded-rounded max-h-full max-w-full object-contain">

This leads to the images not working.

All of these images are imported via the upsertImages method in the image repo, and are passed as simple strings of URLs.

System information

Medusa version 1.16 canary Node.js version: 18 Database: Postgres Operating system: MacOS Ventura 13.4.1 Browser (if relevant): Chrome, but should be the same in all

Steps to reproduce the behavior

Update product with images:

productService.withTransaction(manager).update(product.id, {
            images: imageFiles,
            ...product,
          });

All images in the array imageFiles are just normal strings, i.e:

['url location goes here']

Expected behavior

URLs should either be saved without curly braces and quotes, OR the admin panel should be able to strip them out, like it does for the thumbnails

Screenshots

media image html wrong
olivermrbl commented 1 year ago

Will look into this. Can I get you to try the latest stable version, so we can either rule out or identify that the issues is within recent changes :)

haveamission commented 1 year ago

@olivermrbl I actually experienced it on 1.12 first, which prompted my updating before posting to see if it had gotten a fix, so my guess is that it is consistent. I'll check on 1.15 though.

haveamission commented 1 year ago

Yeah, I was able to confirm it is also happening on 1.15, I also tested on 1.13:

"@medusajs/medusa": "1.15"