This piece of code doesn't seem to work, but i can't figure out why!
first of all: imgWidth, imgHeight, pageWidth and pageHeight are variables defined in other functions and (as you can see) called upon with window.'var'.
Here's what i got sofar:
Code: Select all
function imgResize () {
alert('image-height is ' + window.imgHeight + ' and the page-height ' + window.pageHeight);
if ((window.imgWidth >= window.pagewidth) && (window.imgHeight >= window.pageHeight)) {
var diffMaxWidth = (window.imgWidth - window.pagewidth);
var diffMaxHeight = (window.imgHeight - window.pageHeight);
if (diffMaxWidth > diffMaxHeight) {
//insert set-img-size here; max-width is (window.pagewidth - LightboxOptions.borderSize * 2), height is auto
alert('Too wide and High. Width is bigger.');
}
else {
//insert set-img-size here; max-height is (window.pageHeight - LightboxOptions.borderSize * 2), width is auto
alert('Too wide and High. Height is bigger.');
}
}
else if ((window.imgWidth >= window.pagewidth) && (window.imgHeight < window.pageHeight)) {
//insert set-img-size here; max-width is (window.pagewidth - LightboxOptions.borderSize * 2), height is auto
//let op! is eerder ook gebruikt!
alert('Too wide.');
}
else if ((window.imgWidth < window.pagewidth) && (window.imgHeight >= window.pageHeight)) {
//insert set-img-size here; max-height is (window.pageHeight - LightboxOptions.borderSize * 2), width is auto
//let op! is eerder ook gebruikt!
alert('Too High.');
}
}ps. this is supposed to become a attatchment to Lightbox v2.04