• Register
Welcome to Kodlogs, programming questions and answer website.
+1 vote
292 views
var mainimgcontainer = document.getelementbyid("main-image-container"); var containerwidth =
by (720 points)  

1 Answer

0 votes

Code :

<script type="text/javascript">
    var mainImgContainer = document.getElementById("main-image-container");
    
    var containerWidth = mainImgContainer.offsetWidth;
    //container ratio : width/height
    var holderRatio = 1.0;
    var containerHeight = containerWidth/holderRatio;
    containerHeight = Math.min(containerHeight, 700);
    var dynamicImageMaxHeight = 679 ;
    var dynamicImageMaxWidth = 522 ;
    var landingImage = document.getElementById("landingImage");
    var imgWrapperDiv = document.getElementById("imgTagWrapperId");
    var imageMaxHeight = Math.min(containerHeight, dynamicImageMaxHeight);
    var imageMaxWidth = Math.min(containerWidth, dynamicImageMaxWidth);
    
    var useImageBlockLeftColCentering = false;
    var rightMargin = 32;
    if(typeof useImageBlockLeftColCentering !== "undefined" && useImageBlockLeftColCentering){
        mainImgContainer.style.marginRight = rightMargin + "px";
    }
    mainImgContainer.style.height = containerHeight + "px";
    if(landingImage){
        landingImage.style.maxHeight = imageMaxHeight + "px";
        landingImage.style.maxWidth = imageMaxWidth + "px";
    }
    if(imgWrapperDiv){
        imgWrapperDiv.style.height = containerHeight + "px";
    }
</script>
by (4k points)  
...