Media Optimizer Transformations won't resize if file has no extension.
Hello. Since I am working with NFTs and usually get files using a hash extension (without knowing any info about the file) I have no way of getting images with file extensions. While using the image optimizer, I resize the files before getting them, but only some got resized. I looked into it, and some filed come back with the extension .png, but most do not. Only the files with .png in the image source were resized.
How would I go about resizing every image rather than just images with extensions when using the Media Optimizer for getting remote media files (files that are not hosted by me).
Thanks,
Quok
-
Yes.
Let's say I want to optimize this image:
https://cloudflare-ipfs.com/ipfs/bafybeidgvkie2d2tjzg6cq3e4zzcrn2ikvijwzhcibeeybxfyzr5urfsliI run it through my URL and my card transformation ("c_fill,h_600,w_600/q_auto:best/f_auto"):
https://skyharbor.mo.cloudinary.net/card/https://cloudflare-ipfs.com/ipfs/bafybeidgvkie2d2tjzg6cq3e4zzcrn2ikvijwzhcibeeybxfyzr5urfsliWhile it does get optimized, the image doesn't get resized at all. This is happening to most images on my site. I noticed that the only ones that DO get resized by the transformation are the images with an extension.
Ex)
This image: https://ipfs.io/ipfs/QmQm6rmPcv6aFBeq1ewCNwFxDtxEq9g6CCLkwVYfzV61vF/2447_Gnomekins.pngDOES get resized when run through my link: https://skyharbor.mo.cloudinary.net/card/https://ipfs.io/ipfs/QmQm6rmPcv6aFBeq1ewCNwFxDtxEq9g6CCLkwVYfzV61vF/2447_Gnomekins.png
And the only difference is that it has an extension. -
Hi Quokka,
Effectively, I can reproduce it and Media Optimizer is not able to detect the `resource_type` of the asset without the extension.
If you need to use extension-less URLs, you will need to explicitly specify the `resource_type` like this: https://skyharbor.mo.cloudinary.net/card/https://cloudflare-ipfs.com/ipfs/bafybeidgvkie2d2tjzg6cq3e4zzcrn2ikvijwzhcibeeybxfyzr5urfsli?resource_type=image
Would that work for you?
Best,
Loic
-
Hey Loic! Sorry for the late response, but that issue got fixed and we're up and running now.
I have a new question that I hope you can answer.
Since we don't know what file type something is and we automatically make everything 'resource_type' - is there any way I can turn gifs into images rather than gifs while still using 'resource_type=image'? We have some very large gifs come in and I know converting to videos will make them smaller, but there is no way to know which file is a gif or not before it loads, so our image optimizer just makes every large gif into a webp instead of mp4. What would be your solution for this?
-
Hi Quokka,
In Media Optimizer we recognize if the URL is an image or video based on the extension. Alternatively, you can use the `resource_type` as suggested, to determine if the file is an image or video.
If there is any way to distinguish that the media URL is a gif by looking at its path, for example, if you can pass any query string, then you can create a custom "mapping function" to identify this and return a video file rather than an image.
Let us know if this would work for you,
Thanks,
Michal -
Hey Michal,
There's no way to tell the file type of an image. I see in the cloudinary dashboard that it knows what the original file type is before converting (ex: GIF to webp). Why can we not use this data somehow to go from GIF to mp4? The costs of converting GIF to webp is making cloudinary unusable for us. Is there any other solution for this?
Thanks,
Quokka
-
Hey Quokka, because of your q_auto:best/f_auto your format will vary. If you want to limit a transformation to mp4 you can definitely set it up in your upload presets. You can read more about that here, https://cloudinary.com/documentation/transformations_on_upload
Please sign in to leave a comment.
Comments
10 comments