What the Image Unique Id?

What I want is to know what the unique key of an image from the url? I want send the image which in my Craft pages to my CDN service, and delete those which duplicate.

Web Client upload image is no suffix and the url is shorter, but the Mac side uploaded image has the suffix, and the url is more longer.

Note: I use markdown.craftBlockToMarkdown to get the full image’s real url, not the preview image’s url.

And more, why Web client uploaded image has a grey background?

And more and more I relalize that Mac client uploaded’s image previewUrl and fullUrl all has the image id in url, the difference is preview add _1, full add _2:

Hi, indeed, there is a difference in behavior how the mac and web app generates the image URL.
The “unique key” is a random generated token for security purposes. On the web its the GUID, which is random, thats why its not matching the blockID. It’s because of historical reasons why the app still adds the blockID to the URL, it wouldn’t be necessary.

Although the approaches are different, its intended for both, that the image URL should not be generated automatically from the blockIDs and other IDs, it should be random and looked up from the database, whats the actual URL in the block. The URL format also changed in the past and could change in the future as well, so my recommendation is to look up the blocks and check existing, valid image URLs based on that.

Thanks for reply, I decide to use the img blockId as the unique id, besides, I wonder what the suffix of the image upload by Web Client? it’s not have an suffix, just have an random id in the last of URL.

The last ID in the URL uploaded by the web app is a completely random GUID, so it doesn’t match any known block or document ID. Its similar to the random key in the app’s URL, its just represented in a GUID format.

1 Like