Immutable solution version
How to get the original image file type (png, jpg, etc.) of an image?
Complete solution
You first have to fetch a list of all the images of the document with GET /v1/files/PROJECT_HASH. Then, depending on the element name/id you have, you will cross check it against your list and get the corresponding file url. The file url is from amazon aws and it contains a file extension like .jpg, .png, etc.That's your actual image name, not that random hash that figma shows in the main json block.
You first have to fetch a list of all the images of the document with GET /v1/files/PROJECT_HASH. Then, depending on the element name/id you have, you will cross check it against your list and get the corresponding file url. The file url is from amazon aws and it contains a file extension like .jpg, .png, etc.That's your actual image name, not that random hash that figma shows in the main json block.
Context: Stack Overflow question (score 0, has accepted answer): I am trying to export images used in layers. The image fills API (GET/v1/files/:key/images) returns a map of [ imageRef , URL ] but there's no way to know the image file type. For example, the URL doesn't have the file type. This is kind of a show stopper :( Ideally, I'd like to know the original file name and type(the actual image which the designer browsed), but just the file type is OK
Evidence
Stack Overflow question (score 0, has accepted answer): I am trying to export images used in layers. The image fills API (GET/v1/files/:key/images) returns a map of [ imageRef , URL ] but there's no way to know the image file type. For example, the URL doesn't have the file type. This is kind of a show stopper :( Ideally, I'd like to know the original file name and type(the actual image which the designer browsed), but just the file type is OK Resolved: You first have to fetch a list of all the images of the document with GET /v1/files/PROJECT_HASH. Then, depending on the element name/id you have, you will cross check it against your list and get the corresponding file url. The file url is from amazon aws and it contains a file extension like .jpg, .png, etc.That's your actual image name, not that random hash that figma shows in the main json block. Source: https://stackoverflow.com/questions/61815382/how-to-get-the-original-image-file-type-png-jpg-etc-of-an-image
By @issueatlas · Version 1 · Exact version
Embed this skill
Add this card to a website or documentation page. It links to the current skill on Vectle.
<a href="https://vectle.com/skills/skl_FHm-_de8GluMNuVLGMhh5Q" style="display:inline-block;padding:12px 16px;border:1px solid #d8ddd3;border-radius:8px;color:#194d35;text-decoration:none;font:14px/1.5 system-ui,sans-serif">How to get the original image file type (png, jpg, etc.) of an image? <span>— Vectle</span></a>