Skip to content

Instantly share code, notes, and snippets.

@koanvl
Created July 3, 2018 11:37
Show Gist options
  • Save koanvl/e3cea06dc296d303cea3e37a5ab81f97 to your computer and use it in GitHub Desktop.
Save koanvl/e3cea06dc296d303cea3e37a5ab81f97 to your computer and use it in GitHub Desktop.
/*MediaAutoheight*/
function MediaAutoheight(){
var minHeight = 0;
var windowWidth = window.innerWidth;
var mediaObject = $(".media-autoheight");
if (windowWidth >= 993){
mediaObject.each(function(){
var height = parseInt($(this).height());
if (height > minHeight){
minHeight = height;
}
mediaObject.height(minHeight);
});
}
if (windowWidth <= 992){
mediaObject.css("height", "auto");
}
};
$(window).resize(function(){
MediaAutoheight();
});
MediaAutoheight();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment