Skip to content
  • Recent
  • Tags
  • Popular
  • Users
  • Search
Skins
  • Light
  • 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 421 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


          I also code custom websites or custom Lay features.
          💿 Email me here: 💿
          info@laytheme.com

          Before you post:
          1. When using a WordPress Cache plugin, disable it or clear your cache.
          2. Update Lay Theme and all Lay Theme Addons
          3. Disable all Plugins
          4. Go to Lay Options → Custom CSS & HTML, click "Turn Off All Custom Code", click "Save Changes"

          This often solves issues you might run into

          When you post:
          1. Post a link to where the problem is
          2. Does the problem happen on Chrome, Firefox, Safari or iPhone or Android?
          3. If the problem is difficult to explain, post screenshots / link to a video to explain it
          Online Users
          arminunruhA
          arminunruh
          F
          francesco
          L
          lurchifon
          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