Reaction Commerce Forums

Generate images urls



Anyone knows how to generate the images urls from the product data ?

I have urls looking like that one : https://domain.tld/assets/files/Media/6hQF6EETZPwE8hgJw/productHandle.jpg

Where the does this part comes from 6hQF6EETZPwE8hgJw ? I have a different one for each image.



That’s going to be the _id of the image in Mongo.


Yes, I found it ; this is the _id in the Media collection. So when looking for an image, you have to do

find( { metadata.variantId: product._id } )

Note that this field is not indexed ; neither the metadata.productId. There would be strategies to make that faster and more obvious. Like denormalizing a bit the data by saving the image _id in the product document.