Guest User

Untitled

a guest
Jun 24th, 2018
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.27 KB | None | 0 0
  1. /*! jQuery :isImageFile filter - v0.0.5 - 2014-08-21
  2. *
  3. * Copyright (c) 2013-2018 Jonathan Heilmann;
  4. *
  5. * CHANGELOG
  6. * 0.0.6: -ignore images and links with class "excludeFromMagnificpopup"
  7. * 0.0.5: -ignore images with class "excludeFromMagnificpopup"
  8. * 0.0.4: -fixed bug #59696 (filter-isImageFile doesn't work with UpperCase Filetype)
  9. * 0.0.3: -removed jQuery.noConflict() and added IIFE
  10. * -added support for zepto
  11. * 0.0.2: -added jpeg to filter
  12. * 0.0.1: -initial release
  13. *
  14. */
  15. ;(function($) {
  16. $.extend($.expr[':'], {
  17. isImageFile: function(obj){
  18. var $this = $(obj);
  19. if ($this.hasClass('excludeFromMagnificpopup')) {return false;} // Ignore images and links with class "excludeFromMagnificpopup"
  20. var file = $this.attr('href');
  21. if (file == null) {return false;} // Return false if the path is empty
  22. file = file.toLowerCase(); // Convert to lower case
  23. var extension = file.substr((file.lastIndexOf('.')+1)); // Get extension of file
  24. extension = extension.substr(0, (extension.lastIndexOf('&')));
  25. switch (extension) {
  26. case 'jpeg':
  27. case 'jpg':
  28. case 'png':
  29. case 'gif':
  30. // Got an image - return true
  31. return true;
  32. break;
  33. default:
  34. // No image found - return false
  35. return false;
  36. }
  37. }
  38. });
  39. })(window.jQuery || window.Zepto);
Add Comment
Please, Sign In to add comment