jackmoore / zoom

jQuery plugin for zooming images on mouseover.
http://www.jacklmoore.com/zoom/
MIT License
1.54k stars 460 forks source link

Can't read image url without src or data-src #82

Closed lilyjiang closed 8 years ago

lilyjiang commented 9 years ago

Since I used Breakpoints and Picture modules to make the images responsive in a drupal site, the structure will be like the: img srcset="http://drupal7.com/sites/default/files//public/IMG_2785.jpg 2592w" alt="" title=""

then it can't work on it, because the code is: settings.url = $urlElement.data('src') || $urlElement.attr('src');

I suggest it be: settings.url = $urlElement.data('src') || $urlElement.attr('src') || $urlElement[0].currentSrc;

morgunder commented 8 years ago

could you just add another config option 'img_attr' and then i can use .zoom({img_attr: data-img}) or whatever i need?

related: use of data('src') is not ideal as it reads the initial value of data-src. its preferrable to look in attr('data-src') directly.

jackmoore commented 8 years ago

@lilyjiang My apologies for overlooking this, that sounds like a fine suggestion. I hope you were able to get this to work by using the url option, no need to depend on zoom's defaults.