Resizing Lightbox images

Resizing Lightbox images

I’m using Lightbox2 in my newest project to show images. The images, though, are way too big to show in their original size. I was surprised that I couldn’t find a property or something in the code to resize the images. After some researching on Google and figuring out a resize calculation, I made the following adjustments to the code to resize my images without having to resize each one of them before uploading:

Lightbox.css

Change:
#lightbox img{ width: auto; height: auto;}

To:
#lightbox img{ max-width: 600px; }

Lightbox.js

Change:
imgPreloader.onload = (function(){
this.lightboxImage.src = this.imageArray[this.activeImage][0];
this.resizeImageContainer(imgPreloader.width, imgPreloader.height);
}).bind(this);
imgPreloader.src = this.imageArray[this.activeImage][0];
},

To:
imgPreloader.onload = (function(){
this.lightboxImage.src = this.imageArray[this.activeImage][0];
this.resizeImageContainer(600, imgPreloader.height / (imgPreloader.width/600));
}).bind(this);
imgPreloader.src = this.imageArray[this.activeImage][0];
},

I choose to always show the images with a width of 600px. So, if you want a different width, then change the 600 to the number you choose. You can also go with a height in stead of a width, but then you have to change the calculation formula a bit and use the max-height property in the CSS file.

Flash embed font bold

I use a lot of font types that people don’t normally have installed, so I embed the fonts in Flash. Only, now I tried with actionscript and CSS to make part of a dynamic text field bold. Only, the bold part of the text field wouldn’t show, the text would just not be there.

So, then I found out that when you embed a font in Flash, flash doesn’t include the whole font family automatically. Meaning, that by embedding a regular font, the bold and italic aren’t included.

A workaround for this, is to just add another text field to your stage, somewhere out of sight (or not), and embed the same font type but with bold activated. Run your flash file again and you’ll see that the bold in your other text field is now visible too.

See also: Flash Technote: HTML text fields do not display formatted text