Skip to main content
Inspiring
March 4, 2023
Question

Creating "Save Image As" and "Copy Image To Clipboard" buttons for a gallery

  • March 4, 2023
  • 2 replies
  • 1216 views

Just realized I've never had to implement a "Save Image As" or "Copy Image To Clipboard" button... and now I need to do both for a series of images in a gallery-style webpage.

 

What's the best way to implement both buttons next to an image? Can this be done with HTML alone? Unless there's an existing script out there that will overlay the image with a prompt to Save or Copy if you click it. Those are the two simplest layouts I can think of at the moment.

 

Either way, whatever is easiest to implement would help me out.

 

Thanks!

 

PS: If it makes a difference, my site isn't currently using any JS (just turned out that way, not a conscious decision) but does use PHP to parse includes and variables (which is the extent of my PHP knowledge) in case this influences recommendations in any way.

    This topic has been closed for replies.

    2 replies

    BenPleysier
    Community Expert
    Community Expert
    March 5, 2023

    Try the 'download' attribute on the link as in

    <img src="/images/myimage.jpg" alt="myimage">
    <a download="myimage.jpg" href="/images/myimage.jpg">
        downkoad
    </a>
    

     

    Change the image name and path to suit.

    Wappler is the DMXzone-made Dreamweaver replacement and includes the best of their powerful extensions, as well as much more!
    Under S.Author
    Inspiring
    March 5, 2023

    So there's a built-in "download" attribute I was unaware of, that will be helpful. Thanks. But this only takes care of the SAVE, right? Is there an equivalent attribute for "Copy To Clipboard"?

    Nancy OShea
    Community Expert
    Community Expert
    March 5, 2023
    Nancy OShea
    Community Expert
    Community Expert
    March 4, 2023

    No need to reinvent the wheel for this.

    "Copy image" & "Save Image as" are built-in to your browser's right-click context menu.   See screenshot. 

     

    Nancy O'Shea— Product User & Community Expert