Created
November 22, 2013 00:31
-
-
Save danielwrobert/7592569 to your computer and use it in GitHub Desktop.
Resize images in a gallery list that are too tall - adjusts the height and centers accordingly. *** Not complete - TESTING ***
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// GALLERY IMAGE RESIZER | |
var getMaxOfArray = function(numArray) { | |
return Math.max.apply(null, numArray); | |
}; | |
var getMinOfArray = function(numArray) { | |
return Math.min.apply(null, numArray); | |
}; | |
var galleryImageSize = function(selector) { | |
var imgList = []; | |
// loop through images and get the height of each into an array | |
$(selector).each(function(i,v) { | |
var $this = $(this), | |
imgHeight = $(this).height(); | |
imgList.push(imgHeight); | |
if(imgHeight > getMinOfArray(imgList)) { | |
$this.css({ | |
"width": "auto", | |
"height": getMinOfArray(imgList) + "px", | |
"display": "block", | |
"margin": "0 auto" | |
}); | |
} | |
// TODO: | |
Check for the mode of the array and if imgHeight is less, adjust accordingly as well | |
}); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment