[JavaScript] Lightbox 2 Image größe!

Dieses Thema im Forum "Webentwicklung" wurde erstellt von 3X3X3X3, 7. März 2008 .

  1. 7. März 2008
    Lightbox 2 Image größe!

    Hi RR'ler,
    ich habe mir gerade das Lighbox 2 set runtergeladen und in meine Dokumente eingebunden!
    Klappt auch alles wunderbar!
    So wenn ich aber ein Foto von 2000x2000 px habe und des sich dann in der lightbox öffnet ist es auch 2000x2000px !!!

    So nun will ich dies aber NICH! Ich will das sich das Bild nur an die größe des Bildschirms anpasst!


    Code:
     changeImage: function(imageNum) { 
     
     activeImage = imageNum; // update global var
    
     // hide elements during transition
     if(animate){ Element.show('loading');}
     Element.hide('lightboxImage');
     Element.hide('hoverNav');
     Element.hide('prevLink');
     Element.hide('nextLink');
     Element.hide('imageDataContainer');
     Element.hide('numberDisplay'); 
     
     imgPreloader = new Image();
     
     // once image is preloaded, resize image container
     imgPreloader.onload=function(){
     Element.setSrc('lightboxImage', imageArray[activeImage][0]);
     myLightbox.resizeImageContainer(imgPreloader.width, imgPreloader.height);
     
     imgPreloader.onload=function(){}; // clear onLoad, IE behaves irratically with animated gifs otherwise 
     }
     imgPreloader.src = imageArray[activeImage][0];
     },
    
     //
     // resizeImageContainer()
     //
     resizeImageContainer: function( imgWidth, imgHeight) {
    
     // get curren width and height
     this.widthCurrent = Element.getWidth('outerImageContainer');
     this.heightCurrent = Element.getHeight('outerImageContainer');
    
     // get new width and height
     var widthNew = (imgWidth + (borderSize * 2));
     var heightNew = (imgHeight + (borderSize * 2));
    
     // scalars based on change from old to new
     this.xScale = ( widthNew / this.widthCurrent) * 100;
     this.yScale = ( heightNew / this.heightCurrent) * 100;
    
     // calculate size difference between new and old image, and resize if necessary
     wDiff = this.widthCurrent - widthNew;
     hDiff = this.heightCurrent - heightNew;
    
     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', widthNew);
    
     this.showImage();
     },
     
     //
     // showImage()
     // Display image and begin preloading neighbors.
     //
     showImage: function(){
     Element.hide('loading');
     new Effect.Appear('lightboxImage', { duration: resizeDuration, queue: 'end', afterFinish: function(){ myLightbox.updateDetails(); } });
     this.preloadNeighborImages();
     },
    ^^^^^^^^^^^^^^^^^^^^^^^^
    Des dürfte der Code sein denk ich mal!

    Wie funktiniert das?

    BW geht dann raus

    MfG 3x3x3x3
     
  2. 7. März 2008
    AW: [JAVA] Lightbox 2 Image größe!

    oder noch einfacher!
    wie kann ich beim uploaden die bildgröße in einer vorbestimmten größe hochladen! oder besser gesagt bei hochladen "kompremieren"? Das würde das ganze Problem ja auch schon lösen!

    Die Bilder sind ja immer 1024x768 zum Beispiel!
    D.h. x ist in dem Fall 1024 und somit größer als y = 768!
    Jetzt da x > y will ich das Bild auf 250x200 "kompremieren"!
    wenn aber y > x dann soll das Bild auf 200x250 gemacht werde!..

    Wer mir helfen kann bekommt ne BW!

    Mein Script sieht so aus:

    bildupload.php
    Code:
    <FORM ENCTYPE="multipart/form-data" ACTION="bildupload.php" METHOD=POST>
    Datei:<br>
    <INPUT NAME="datei" TYPE="file"><BR>
    <INPUT TYPE="submit" VALUE="Upload">
    </FORM>
    
    <?
    $handle=opendir ('.');
    $sum = 0;
    
    while (false !== ($file = readdir ($handle))) 
    {
     $sum += filesize($file);
    }
    
    $neu = $sum / 1024000;
    closedir($handle);
    
    if (isset($datei))
    {
     echo "Dateiname: $datei_name<br>";
     echo "Größe: $datei_size Bytes<br>";
     echo "Type: $datei_type<br><br>";
     copy($datei, $datei_name);
    
    [I]"Hier dann DB eintrag.."[/I]
    }
    ?>
    
     
  3. 10. März 2008
    AW: [JAVA] Lightbox 2 Image größe!

    bist im falschen thread falls du das net gemerkt hast, du sprichst hier von web dingen, hier sind wir aber im PROGRAMMIER forum, da ist fertig klicki-bunti und es wird dir auch niemand helfen...
     
  4. 10. März 2008
    AW: [JAVA] Lightbox 2 Image größe!

    Ich verschiebs mal nach Webtechnik.
    Vielleicht koennen da mehr Leute helfen

    ~moved~
     
  5. Video Script

    Videos zum Themenbereich

    * gefundene Videos auf YouTube, anhand der Überschrift.