Closed deurzen closed 2 years ago
Hi @deurzen,
Thank you for the information.
I will review the issue internally and keep you posted.
Regards, Wissam
Hi @deurzen,
You may apply an individual transformation(s) to a product catalog in Magento. In Magento Admin, navigate to Catalog > Products. On this Products page, each product should be listed and an option to 'Edit' under Action column. Clicking on 'Edit' should take you to the Product Edit page. Collapse the Cloudinary Section, here is an option to enter Cloudinary transformation in the transformation field. Enter your intended transformation. Note: when using a named transformation prepend the named transformation with a t_<named_transformation>
(e.g. t_media_lib_thumb
). Let me know if this is what you're looking for.
Regards, Anthony
Hello Wissam @wissam-khalili and Anthony @atdcloud,
Thank you both for having a look at the issue!
@atdcloud Thanks, that does seem to be a way to do it. The workflow currently would thus entail (1) adding the intended base image a second time (as the first base image should not undergo the thumbnail transformation), (2) labeling it Thumbnail
, and then (3) applying a custom transformation to it manually, for each product. Perhaps a nice feature might be the ability to configure 'image', 'small', and 'thumbnail' (and even 'gallery'?) image transformations at a global level. That is, each image type would be given their respective globally-configured transformation automatically, without needing to add it manually for each product.
A few issues seem to be present in this workflow, however:
null
under cld_data: { thumbnail }
.Kind regards, Max
Hi @deurzen,
Thank you for the additional information.
I am reviewing this issue internally and will keep you posted.
Thanks, Wissam
@wissam-khalili, that's much appreciated, thank you!
Hi @deurzen, can you please send us which GraphQL plug-in (preferably the Packagist link) is installed in your Magento environment?
Hello @atdcloud,
Inspecting my project's composer.lock
file, my Magento 2.4.4 instance (magento/product-community-edition 2.4.4
) requires webonyx/graphql-php ~14.11.3
. The actual version installed for webonyx/graphql-php
(from that same composer.lock
file) is currently version 14.11.6
https://packagist.org/packages/webonyx/graphql-php#v14.11.6 (i.e. the last non-dev version at the time of this writing). I'm on version 1.18.0
of cloudinary/cloudinary-magento2
.
Thanks, Max
Hi @deurzen,
I have yet to mimic your environment but can you query your REST API with the following endpoint (cloudinary/products/:sku/media)? Let me know what is the response. It should be in the following format:
{
"data": {
"image": "<cloudinary url>",
"small_image": "<cloudinary url>",
"thumbnail": "<cloudinary url>",
"media_gallery": [
"<cloudinary url>"
]
}
}
Hello @atdcloud,
I checked the response on the REST endpoint, as you suggested, and it returned the exact same results as the ones I got from GraphQL: image
, small_image
, and thumbnail
are all equal. Also, any custom transformations passed in through Product > Cloudinary are not propagating (i.e. not showing up as part of the returned URL).
Hi @deurzen, After some digging into the source code, querying to get the custom transformation in graphql is not currently implemented on our plug-in. It is currently not defined in the schema graphqls. Sorry for any inconvenience.
In case anyone else stumbles across this issue looking for access to cloudinary through Magento's GraphQL API, I've solved it as follows:
image: { label }
and media_gallery: { label }
fields, which will yield each of the images' public IDs; andFor instance:
// assuming `products` contains the resolved result of the query
products.forEach(product => {
product.image.url = buildImageUrl(product.image.label, {
cloud: {
cloudName: process.env.CLOUDINARY_CLOUD_NAME,
},
transformations: {
format: 'auto',
transformation: 'thumbnail', // any custom transformations you may have
quality: null,
},
});
});
Hi @deurzen, Thank you for sharing your solution.
Querying a store's products through GraphQL on Magento 2.4, with the latest version of the extension installed (1.18.0), the image URLs returned (image, small_image, thumbnail) are all the same. For example, the following query:
Yields the following result:
Is this expected behavior? These queries are made while building a static website using NextJS. The images returned are consequently at their original, unoptimized size of ~8MP. I have a custom thumbnail transformation set up on the Cloudinary side, but there's no way to pass them on through the plugin's configuration in Magento. The only option is to apply a transformation to all product images. What would the recommended workflow be when using Magento only as a headless backend? Thanks.