Click to Copy Image Using Browser Component

Hi All,

I’m trying to set up an action on a button to copy a QR code using the browser component.

However, when I look at my browser component (Wappler 6.5.2 stable) all I can see is ‘Write text to clipboard’ and there is no way to select my image:

image

I’ve seen older versions of this in this form that show a ‘Copy to clipboard’ choice.

Am I doing something wrong here?

We do a similar thing with QR codes but on click they copy the link to the page to the Clipboard.

Or a simple Codepen example here Tom. This will prompt to save the image on click if that helps…

1 Like

I was looking to copy the image as the reason for it is for the client to copy the image so it can be printed off / sent to printing departments so it can be printed to magnetic stickers etc.

Thanks for the Codepen, that’s exactly what I’m after and I’ll implement it, it would be great if Wappler could do this natively though.

I believe the old Copy to clipboard you are referring to was using execCommand('copy') and copied the selected item to the clipboard. This method is however deprecated and not longer recommended.

The new Clipboard API is supported by all mayor browsers and allows you to read/write the clipboard async. The API only works for websites served using https and require user permissions. The writeText is supported by all browsers, the write is supported by most but not by Firefox (it is in the latest nightly).

Copying an image also isn’t that simple with the new API, see following article:

Is there a reason why you want to copy the QR code as an image? Why not copy the url or the text content that the QR code actual represents.

Thanks for that update, it looks like I’ll have to try and find another way to do that.

My use case is as follows:

Why not a button to download the image instead of copy to clipboard, many programs don’t support pasting image from clipboard and accessing clipboard from the browser requires extra permissions.