Created
November 20, 2021 15:12
-
-
Save lucas-pelton/f168893f59f09009413c444f7da28677 to your computer and use it in GitHub Desktop.
Size all selected images to similar visual gravity
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
/********* | |
* | |
* resize logos in custom galleries. | |
* | |
*/ | |
window.addEventListener("load", function() { | |
var images = document.querySelectorAll(".custom-gallery img"); | |
var adjustImageWidth = function (image) { | |
var widthBase = 250; | |
var scaleFactor = 0.525; | |
var imageRatio = image.naturalWidth / image.naturalHeight; | |
image.width = Math.pow(imageRatio, scaleFactor) * widthBase; | |
} | |
images.forEach(adjustImageWidth); | |
}, false); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment