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.68k stars 298 forks source link

thumbnailPath function can now signal to revert to default functionality #363

Open ericnewton76 opened 2 years ago

ericnewton76 commented 2 years ago

I ran into an issue, where I'm loading Video preview urls from (youtube/vimeo) and self hosted Images that have an endpoint similar to Flikr. I was using sizeRangeSuffixes to rewrite the self hosted images but this was also applying to the Preview images hosted by youtube/vimeo which dont support this.

The goal was to provide a function to thumbnailPath to just handle videos (leave them alone) and apply sizeRangeSuffixes to all the other images.

In the process, I found a bug where this.resetImgSrc was undefined inside the error handler due to jQuery rewriting what this is.

Example usage:


thumbnailPath: function(src, w, h, img) {

  if($(img).data("isVideo") == "true") {
    return src;
  else
    return null; //fallback to default handling that can use sizeRangeSuffixes

}
ericnewton76 commented 2 years ago

BTW tried to run npm test but it errors with: qunit task doesnt exist in gruntfile.

I didnt update dist yet, assuming grunt might do this?

ericnewton76 commented 2 years ago

Note, I added a final commit which sets version to 3.9.0, bumping the 3.8 to 3.9 due to the new non-breaking functionality. I enscribed the version 3.9.0-645d8e1 in the files so that I could go ahead and integrate this into my project with the acknowledgement to somebody else that its a prerelease.

Also, I had to hand edit the dist/js/ files because the grunt replace task wasnt replacing //JG-CONTROLLER with the contents of dist/js/justifiedGallery.js. I tried a few things there and just couldnt get it to work and did it manually. (I'm running on Windows, perhaps something related to that)

I would recommend maybe retarget this PR into another branch or master and hard set the version to 3.9.0 (removing the prelease monikor) and do a final grunt run.