napchart-website icon indicating copy to clipboard operation
napchart-website copied to clipboard

Add file extension to api/getImage

Open larskarbo opened this issue 6 years ago • 4 comments

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

larskarbo avatar Feb 27 '18 16:02 larskarbo

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

larskarbo avatar Feb 27 '18 16:02 larskarbo

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.

jrobber avatar Feb 28 '18 02:02 jrobber

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 ?

larskarbo avatar Feb 28 '18 15:02 larskarbo

Yes, that change sounds good.

jrobber avatar Mar 04 '18 19:03 jrobber