How are image links generated?

AI-generated summary

The discussion is about how image links are generated in Discourse. TheBestPessimist asks if it’s possible to link to an image using the “upload link” (![image|690x459](upload://nkjFnpawJaOanmycDbIXVG4jlkn.jpeg)), and how to find other versions of the image, such as retina or mobile versions. zogstrip explains that the upload link is a custom URL scheme that only works within the same Discourse instance, and that there are original and thumbnail versions of images generated to support different pixel ratios.

TheBestPessimist clarifies that they are interested in getting the original link, and notes that the link provided by “Copy link address” is not the same as the original link on S3. zogstrip explains that the two links are the same file, but one is on the CDN and the other is on S3.

Finally, codinghorror provides a simple solution to the problem: clicking or tapping on the image and then clicking or tapping the download link at the bottom will provide the original image link.

Here’s a large image:

Its original link is: https://cdck-file-uploads-global.s3.dualstack.us-west-2.amazonaws.com/meta/original/3X/a/3/a37df25f15fccd47dc543f3d5751d81cb61dbe6b.jpeg
Which is different from ![image|690x459](upload://nkjFnpawJaOanmycDbIXVG4jlkn.jpeg)

It will however, also have multiple optimized (for size and dimensions) versions.
Here’s one i got: https://global.discourse-cdn.com/meta/optimized/3X/a/3/a37df25f15fccd47dc543f3d5751d81cb61dbe6b_2_690x459.jpeg.

My questions are:

  • can i link somehow to the image via the “upload link”: ![image|690x459](upload://nkjFnpawJaOanmycDbIXVG4jlkn.jpeg) (eg: https://meta.discourse.org/uploads/nkjFnpawJaOanmycDbIXVG4jlkn.jpeg) => i would expect that discourse will redirect me to the correct url afterwards.
  • how can i know what other links/versions of my image are created?
    eg. :
    • https://cdck-file-uploads-global.s3.dualstack.us-west-2.amazonaws.com/meta/original/3X/a/3/a37df25f15fccd47dc543f3d5751d81cb61dbe6b.jpeg
    • or maybe https://cdck-file-uploads-global.s3.dualstack.us-west-2.amazonaws.com/meta/original/>>>2<<<X/a/3/a37df25f15fccd47dc543f3d5751d81cb61dbe6b.jpeg (this one doesnt exist)
    • other versions for retina, mobile, idk?

Since it’s a custom URL scheme, that kind of link will only work in a Discourse instance. Plus, if you want the link to actually work, it’ll need to be a link to an image on the same instance.

Why would you want to know? In Discourse, there are the “original” and a bunch of thumbnails (what we call optimized) which are mostly generated to support different pixel ratios.

Well, i’m mostly interested in getting the original link.

Right now if Copy link address:

on my picture above i get

https://global.discourse-cdn.com/meta/original/3X/a/3/a37df25f15fccd47dc543f3d5751d81cb61dbe6b.jpeg

which even although has original in the name, is not the same as

https://cdck-file-uploads-global.s3.dualstack.us-west-2.amazonaws.com/meta/original/3X/a/3/a37df25f15fccd47dc543f3d5751d81cb61dbe6b.jpeg.

My point is that if in the future discourse would change the cdn, all the links with the old cdn will be broken.

That’s the exact same file (cue the filename), except your 1st link is on the CDN and the 2nd link is on S3 (the storage we use here on meta).

i just modified the post again (sry, i though you werent gonna answer that fast :blush: )

Click / tap the image and click / tap the download link at the bottom. Problem solved.