napchart-website
napchart-website copied to clipboard
Add file extension to api/getImage
From @JRobber on February 27, 2018 10:27
A number of websites are skeptical of allowing images from urls without file extensions (like discord).
Would you consider updating api/getImage to generate with a file extension?
simply changing it to api/getImage.jpg or api/getImage.png and updating your endpoints might work (haven't tried this)
Copied from original issue: larskarbo/napchart#46
How does this impact sites like discord specifically?
I think you actually are right, it is best practice to include extension in image urls. Will have a look next time I'm updating the API
I'm a little old school so I looked it up to make sure I was current, and it's less of a big deal than it used to be. https://stackoverflow.com/questions/5110384/can-i-use-images-without-extension-in-img
TLDR; Without a file extension the image needs a MIME/type associated to figure out what to do. In many non-standard browser apps they don't support that kind of meta information yet and rely on the file extensions. But in modern browsers it does fine.
The Cloudinary image service structures URL's this way:
https://res.cloudinary.com/<cloud_name>/image/upload/<public_id>.<format>
Can probably change the API endpoint to getImage.png?params
, but we should keep an alias with getImage?params
to preserve backwards compatibility
Also have to change the template file to serve the .png
version
@JRobber does it sound OK, or should we change the structure/filename/path more ?
Yes, that change sounds good.