Hi.
This does not answer all questions in the forum for adjusting width
and height dynamically with fancybox, however, it may be of value to
those of you that need a general method of specifying width and height
on varying elements without having to modify the fancybox source code.
In switching from Thickbox, I needed something that followed
Thickbox's way of sizing the frame based on url parameters. Here's a
simple bit of code so that each link can have it's own width/height
specified:
$(document).ready(function(){
$('a.fancybox').each(function(){
var fWidth = parseInt($(this).attr('href').match(/width=[0-9]+/i)
[0].replace('width=',''));
var fHeight = parseInt($(this).attr('href').match(/height=[0-9]+/i)
[0].replace('height=',''));
$(this).fancybox({'frameWidth':fWidth,'frameHeight':fHeight});
});
});
HTML:
<a class="fancybox" href="
http://www.google.com?
iframe&width=400&height=300">Google</a><br /><br />
<a class="fancybox" href="
http://www.yahoo.com?
iframe&width=800&height=1000">Yahoo</a><br /><br />
<a class="fancybox" href="
http://jquery.com?
iframe&width=100&height=100">jquery</a><br /><br />
This method can of course be extended such that the url parameters (or
some other attribute) can specify unique settings for initializing
fancybox. Hopefully, it will get you guys thinking on another level
to make this tool more scalable to meet your needs.
For dynamically scaling the frame based on loaded content (i.e., after
ajax or image is loaded into the iframe), you will either have to
modify the source code or use another tool such as NyroModal).
Good luck!