vvvmax / unitegallery

Unite Gallery - Responsive jQuery Image and Video Gallery Plugin. Aim to be the best gallery on the web on it's kind. See demo here:
http://unitegallery.net
MIT License
530 stars 158 forks source link

handling of img attributes is not implemented as documented #118

Open h0lg opened 7 years ago

h0lg commented 7 years ago

The documentation says about the treatment of the img tag attributes:

src - url of the thumbnail image data-image - url of the big image.

Trying that, however, the thumbnail is ignored. That means calling of var objItem = api.getItem(); both objItem.urlThumb and objItem.urlImage hold the URL of the big image i put in the data-image attribute.

I think I identified the part of the source responsible for it. Here are the lines I mean (19761 to 19777):

                 //get the big image
                 var imageSrc = objChild.data("image");
                 if(!imageSrc || typeof imageSrc == "undefined")                 
                     imageSrc = objChild.attr("src");

                 var dataThumb = objChild.data("thumb");

                 //if exists data-thumb, then the big image is src
                 if(typeof dataThumb != "undefined" && dataThumb != ""){
                     objItem.urlThumb = dataThumb;
                     objItem.urlImage = imageSrc;
                     //objChild.attr("src", dataThumb);
                 }else{
                     //if not, the thumb is src
                     objItem.urlThumb = imageSrc;
                     objItem.urlImage = objChild.data("image");
                 }

The issue is in the line objItem.urlThumb = imageSrc; because imageSrc has been initialized with var imageSrc = objChild.data("image");. Now I'm not sure whether I fully understand this code. It seems to me to try to

  1. set objItem.urlThumb preferred from data-thumb, otherwise from src
  2. set objItem.urlImage preferred from data-image, otherwise from src

If I understand correctly, I suggest the following code instead to fix the issue:

var src = objChild.attr("src");
objItem.urlThumb = objChild.data("thumb") || src;
objItem.urlImage = objChild.data("image") || src;

Thanks and keep up the good work!

vvvmax commented 7 years ago

Hi. It should work ok. Could you please make some test case where it works not on and if will be some bug ill fix it. Please write to: valiano.ticksy.com its more complicated in the code because i use tge gallery html output in variaty of ways in cms versions.

On Friday, November 4, 2016, Holger Schmidt notifications@github.com wrote:

The documentation says about the treatment of the img tag attributes: http://unitegallery.net/index.php?page=documentation#installing_the_gallery

src - url of the thumbnail image data-image - url of the big image.

Trying that, however, the thumbnail is ignored. That means calling of var objItem = api.getItem(); both objItem.urlThumb and objItem.urlImage hold the URL of the big image i put in the data-image attribute.

I think I identified the part of the source responsible for it. Here are the lines I mean (19761 to 19777):

           //get the big image
           var imageSrc = objChild.data("image");
           if(!imageSrc || typeof imageSrc == "undefined")                
               imageSrc = objChild.attr("src");

           var dataThumb = objChild.data("thumb");

           //if exists data-thumb, then the big image is src
           if(typeof dataThumb != "undefined" && dataThumb != ""){
               objItem.urlThumb = dataThumb;
               objItem.urlImage = imageSrc;
               //objChild.attr("src", dataThumb);
           }else{
               //if not, the thumb is src
               objItem.urlThumb = imageSrc;
               objItem.urlImage = objChild.data("image");
           }

The issue is in the line objItem.urlThumb = imageSrc; because imageSrc has been initialized with var imageSrc = objChild.data("image");. Now I'm not sure whether I fully understand this code. It seems to me to try to

  1. set objItem.urlThumb preferred from data-thumb, otherwise from src
  2. set objItem.urlImage preferred from data-image, otherwise from src

If I understand correctly, I suggest the following code instead to fix the issue:

var src = objChild.attr("src");objItem.urlThumb = objChild.data("thumb") || src;objItem.urlImage = objChild.data("image") || src;

Thanks and keep up the good work!

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/vvvmax/unitegallery/issues/118, or mute the thread https://github.com/notifications/unsubscribe-auth/AC_K_uTePRNvt0SNF0P3tJTyk69XglOXks5q62_rgaJpZM4Kp0KK .