Óscar
unread,Oct 28, 2009, 9:02:46 AM10/28/09Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to fancybox
Hi.
(sorry for my english)
I was trying to use fancybox with a gallery where some of the pictures
(around 100px) where smaller than captions, that sometimes are quite
large.
Text is broken in two or more lines and width is set to image width,
so final aspect is horrible (I think is stupid using fancybox for so
small images, but it's not my decision).
I've tried several changes with css but IE6 is not working anyhow, so
I've modified the script this way:
I've added a new option 'minWidth' when fancybox is called:
$.fn.fancybox.defaults = {
minWidth : 250
};
And then, introduced conditional for minWidth. When images are bigger,
script takes their own size, and when images are smaller, background
and caption width are set to minWidth.
With some css changes, it's easy to center the image in the
background.
function _proceed_image() {
if (opts.imageScale) {
var w = $.fn.fancybox.getViewport();
var r = Math.min(Math.min(w[0] - 36, imagePreloader.width) /
imagePreloader.width, Math.min(w[1] - 60, imagePreloader.height) /
imagePreloader.height);
if (opts.minWidth > 0 )
{
if (opts.minWidth > imagePreloader.width )
{
var width = opts.minWidth;
}
else {
var width = Math.round(r * imagePreloader.width);
}
}
else
{
var width = Math.round(r * imagePreloader.width);
}
var height = Math.round(r * imagePreloader.height);
} else {
var width = imagePreloader.width;
var height = imagePreloader.height;
}
_set_content('<img alt="" id="fancy_img" src="' + imagePreloader.src +
'" />', width, height);
};
Maybe fancybox has some way to do this, but I don't know how.
I think it would be a good idea to implement this option in future
versions.
Thanks.