Организуйте и загружайте варианты изображений в Medusa
Adds the ability to give each product variant its own thumbnail and ordered images
1yarn add @meduline/medusa-plugin-variant-images2
3npm i @meduline/medusa-plugin-variant-imagesTo use this plugin, you need to have the minimum versions of the following dependencies:
1"@medusajs/admin-sdk": "^2.8.2",2"@medusajs/cli": "^2.8.2",3"@medusajs/framework": "^2.8.2",4"@medusajs/icons": "^2.8.2",5"@medusajs/js-sdk": "^2.8.2",6"@medusajs/medusa": "^2.8.2",1plugins: [2 {3 resolve: ' @meduline/medusa-plugin-variant-images',4 options: {},5 },6],npx medusa db:migrate1fields: "+metadata";2
3// Example4sdk.client.fetch(`/store/products`, {5 query: {6 fields: "{other fields},+metadata", // <-- ADD +metadata HERE7 },8});Once you have done all of the above, you will be able to access the variant images from each product variant's metadata.
1type Images = {2 url: string;3};4
5// Example6const thumbnail: string | null | undefined = variant.metadata.thumbnail;7const images: Images[] | undefined = variant.metadata?.images;See a bug? Please raise an issue on the GitHub repository.
Want something to change? Feel free to clone the repository and open a PR once you have added your feature, or please open a feature request.
This plugin has been forked from https://github.com/Betanoir/medusa-variant-images to work with Medusa 2.10.1 and above.