Support » Plugin: YITH WooCommerce Zoom Magnifier » Downloadable image

  • Hello!

    I would like download the main image by right click, but I can’t it due to zoom. Therefore, I put a download link in the code (<a href="img_src" download></a>) and I would like change href attribute when click thumbnails. First click I can change, but then doesn’t work. How can I call my function after thumbnail swatch?

    $('.yith_magnifier_gallery li a').on('click', function() {
      $('btn-download').attr('href', this.href);
    });

    Thanks,
    Udvi

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author YITHEMES

    (@yithemes)

    Hi,
    it seems that the code provided contains some errors, for example
    $(‘btn-download’) should be a CSS class selector?
    ‘download’ should be the anchor text?

    Please fix them and retry

    Thread Starter UdVi86

    (@udvi86)

    Hello!

    Yes, ‘.btn-download’ is a class. The ‘download’ is an attribute, force image download, not open new window: http://www.w3schools.com/tags/att_a_download.asp

    <a href="image-src" class="btn-download" download></a>
    – this is the product-image-magnifier.php

    $('.yith_magnifier_gallery li a').on('click', function() {
      $('.btn-download').attr('href', this.href);
    });

    – this is my own script

    But now I rewrite yith-magnifier.js. Put the next lines:

    $.yith_magnifier.defaults = {
      ...
      elements: {
        ...
        button: $('.main-image .btn-download')
      }
    }

    and

    $.yith_magnifier.prototype = {
      ...
      _initGallery: function () {
        ...
        var button = elements.button
        ...
        if (gallery.length > 0) {
          button.attr('href', this.href);
        }
      }
    }

    This work, but the plugin don’t update anymore. How can I extend this functions?

    Thanks.

    • This reply was modified 4 years, 8 months ago by UdVi86.
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Downloadable image’ is closed to new replies.