Nie ma możliwości zczytania rozmiarów obrazu przez samo JS?
W php nie mam żadnego problemu zrobić coś takiego... Ale widziałem rozwiązanie i wydawało mi się że było w samym JS...
Poprzeglądam jeszcze biblioteki lightbox'a... On nie korzysta z php, a ładnie dopasowuje się do zdjęcia...
Kod
resizeImageContainer: function( imgWidth, imgHeight) {
// get current height and width
this.wCur = Element.getWidth('outerImageContainer');
this.hCur = Element.getHeight('outerImageContainer');
// scalars based on change from old to new
this.xScale = ((imgWidth + (borderSize * 2)) / this.wCur) * 100;
this.yScale = ((imgHeight + (borderSize * 2)) / this.hCur) * 100;
// calculate size difference between new and old image, and resize if necessary
wDiff = (this.wCur - borderSize * 2) - imgWidth;
hDiff = (this.hCur - borderSize * 2) - imgHeight;
if(!( hDiff == 0)){ new Effect.Scale('outerImageContainer', this.yScale, {scaleX: false, duration: resizeDuration, queue: 'front'}); }
if(!( wDiff == 0)){ new Effect.Scale('outerImageContainer', this.xScale, {scaleY: false, delay: resizeDuration, duration: resizeDuration}); }
// if new and old image are same size and no scaling transition is necessary,
// do a quick pause to prevent image flicker.
if((hDiff == 0) && (wDiff == 0)){
if (navigator.appVersion.indexOf("MSIE")!=-1){ pause(250); } else { pause(100);}
}
Element.setHeight('prevLink', imgHeight);
Element.setHeight('nextLink', imgHeight);
Element.setWidth( 'imageDataContainer', imgWidth + (borderSize * 2));
this.showImage();
},
EDIT:Z lightbox'a wyciągnąłem taki oto kod powyżej... Myśle że tutaj coś jest, ale nie jestem pewien.
Na JS niestety nie znam się poza funkcją writeln

...?