Skip to content
  • Recent
  • Tags
  • Popular
  • Users
  • Search
Skins
  • Light
  • Brite
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse

Lay Theme Forum

  1. Home
  2. General Discussion
  3. Automatically Download Images Upon Click (jQuery)

Automatically Download Images Upon Click (jQuery)

Scheduled Pinned Locked Moved General Discussion
4 Posts 2 Posters 751 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • kurtwoerpelK Offline
    kurtwoerpelK Offline
    kurtwoerpel
    wrote on last edited by
    #1

    Hello Armin and Crew,

    I'm trying to get images to automatically download upon click and can't seem to crack the code. I read up on the particulars of your 'bind to click' jquery on the site and have tried to approximate mine based on some other web tutorials, but can't seem to crack it.

    Here's what I have now:

    jQuery(document).on("click", ".clickme", function(event){
    var link = $(“<a></a>”);
    var source = $(this).attr(“src”)
    link.attr(“href”, source);
    link.attr(“download”, “filename”)
    link.attr(“target”, “_blank”)
    JQuery(link).css(“display”, ”none”);
    JQuery(“body”).append(link);
    link.click()
    JQuery(link).remove()
    })

    Does not seem to do anything -- any advice?

    Thanks so much!

    Kurt

    1 Reply Last reply
    0
    • mariusjopenM Offline
      mariusjopenM Offline
      mariusjopen
      Global Moderator
      wrote on last edited by
      #2

      Dear @kurtwoerpel

      do you have many images?
      You could just link them to the image file from your MEDIA LIBRARY.

      I think your jQuery code is a bit too complicated.

      I would make a JS Fiddle to test.

      Not sure if you need this:

      var link = $(“<a></a>”);
      

      You just need the Source and then open the source again in a new window.

      Best!

      Marius

      www.mariusjopen.world

      1 Reply Last reply
      0
      • kurtwoerpelK Offline
        kurtwoerpelK Offline
        kurtwoerpel
        wrote on last edited by
        #3

        Hmmmmm.

        I will fiddle around ;)

        I'm having trouble even having jQuery recognize or trigger from images.
        Is there a specific way i have to refer to images in LayTheme?

        1 Reply Last reply
        0
        • mariusjopenM Offline
          mariusjopenM Offline
          mariusjopen
          Global Moderator
          wrote on last edited by
          #4

          Dear @kurtwoerpel

          give this a try.

          <script>
          jQuery(document).on("click", "img", function(event) {
          	jQuery(this).addCLass("TEST");
          });
          </script>
          

          Best!

          Marius

          www.mariusjopen.world

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          Online Users
          Forgot your key, lost your files, need a previous Lay Theme or Addon version? Go to www.laykeymanager.com
          laytheme.com
          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Recent
          • Tags
          • Popular
          • Users
          • Search