Image Download button

Hey there
I am trying to provide a download button in my frontend component to download images from a image gallery. its embarassing but i stuck with just downloading corrupt files.
i tried it like s:

    <a href={downloadlink} download="img.png">some link</a>

for the downloadlink i try to use the media.url prop
what am i missing?
thanks

Hey Michael, we're happy to help.

The download attribute doesn't seem right. It goes by itself. So maybe something like this:

<a href={downloadlink} download> Some link </a>

Using the download attribute in the anchor isn't something that isn't working as it used to anymore. There are many resources online explaining why; this one, for example, outlines why browsers don't support this attribute as a security measurement.

If your resource to be downloaded isn't served from the exact origin or the same server as your app, it won't get downloaded. A quick workaround would be to add a target="_blank" attribute to the anchor tag so that the page at least opens in a new tab.

<a href={media.url} download target="_blank">some link</a>

Let me know if this helps you.