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?

Hey Michael, I'm more than 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.

Basically, if your resource to be downloaded isn't served from the same origin or same server as your app, it won't get downloaded. A quick workaround would be to just 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

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.