miromannino / Justified-Gallery

Javascript library to help creating high quality justified galleries of images. Used by thousands of websites as well as the photography community 500px.
http://miromannino.github.io/Justified-Gallery/
MIT License
1.7k stars 299 forks source link

thumbnailPath function is not being called #184

Closed propertunist closed 8 years ago

propertunist commented 8 years ago

i am testing the thumbnailPath feature here and have found that it is not working correctly. i added a 'console.log' command to the function that i am using within thumbnailPath and it is not being output to the browser console, so it seems that the function is never being run. this is the code i am using for the parameter:

thumbnailPath: function (currentPath, width, height) {
                        console.log('thumbnailpath = ' + currentPath);
                        if (Math.max(width, height) < 250) {
                            return currentPath.replace(/(.*)(small)(.*)/gi, "$1large$3");
                        } else {
                            return currentPath;
                        }
                    }
propertunist commented 8 years ago

so i have found that part of the cause of this is that the structure of my gallery is:

container div
    item div
        a hyperlink
            img

and the selector value i am using when calling the justified-gallery plugin is:

'> .elgg-item > a > img'

so when this function runs: JustifiedGallery.prototype.imgFromEntry the entry is already an image and this this function fails.

however, if i remove the img from the selector then the imgFromEntry function works correctly, but the layout of the resulting gallery is broken.

propertunist commented 8 years ago

this has been resolved by me pointing the selector to the div that contains the images and correcting the CSS to make sure the items render correctly.