larskarbo / napchart-website

Full stack website utilizing the napchart library to create, save and share napcharts.
https://napchart.com/
30 stars 20 forks source link

Add file extension to api/getImage #6

Open larskarbo opened 6 years ago

larskarbo commented 6 years ago

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 commented 6 years ago

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

jrobber commented 6 years ago

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.

larskarbo commented 6 years ago

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 ?

jrobber commented 6 years ago

Yes, that change sounds good.