Open 3200creative opened 4 years ago
Sanity lets you add a filename at the end of the url and return the originalFilename (or any wanted name) like this:
https://cdn.sanity.io/images/{project-id}/{dataset}/{hashed-name}/{originalFilename}?params..
Your image URL would in this case be: https://cdn.sanity.io/images/ndjrels0/production/7b1b7cc7a4cf094b24cfd1ea6a6fa224865bc9e0-1200x800.png/the-incredible-hulk.webp?fm=webp
Hi!
@mattias-lonn how would you get hold of the {originalFilename} in this case? Lets say that you grok an asset reference by doing asset->{url} or something, then you would get the something like urlpath/68167e1c7d2bc14d7be0a0bc01e2bb36e9ec76c2.yaml right. But let's say the uploaded name is test.yaml, where would you get that variable?
Thanks, Andreas
I'm optimizing images for SEO and can't seem to solve this issue:
I'd like to keep the image filename somewhere within the final images filenames I've found the option for 'storeOriginalFilename' however I'm having trouble passing it to the final filenames of the generated images.
Example of sanity auto-generated filenames being indexed with Google: If you google 7b1b7cc7a4cf094b24cfd1ea6a6fa224865bc9e0 you'll get the incredible hulk due to the filename at: https://www.knutmelvaer.no/
Is there an example or documentation on how to accomplish this? Thanks in advance.