i have a simple tag based image gallery which saves all images in a database. To show these images there is a small php script
<?php
include_once("config/config.php");
$mysql_user = USER;
$password = PWD;
$database_host = HOST;
$database = DB;
mysql_connect($database_host, $mysql_user, $password) or die ("Unable to connect to DB server. Error: ".mysql_error());
mysql_select_db($database);
header('Content-type: image/jpeg');
$query = "SELECT imgblob from images where id=". intval($_GET["id"]);
$rs = mysql_fetch_array(mysql_query($query));
//echo mysql_error();
echo base64_decode($rs["imgblob"]);
?>
After a search there is a list of images that looks like
<a class="lightbox" href="showimage.php?id=1" title="" ><img src="showimage.php?id=1" /></a>
I use lightbox to resize the image on click. So i need to get the size of the image source (showimage.php?id=1).
I have the following code snippet
$('a.lightbox').each(function() {
var img = $(this).children("img");
var theImage = new Image();
theImage.src = img.attr("src");
$(this).fancybox({
'transitionIn' : 'elastic',
'transitionOut' : 'elastic',
'speedIn' : 600,
'speedOut' : 200,
'overlayShow' : false,
'type' : 'iframe',
'width' : theImage.width + 20,
'height' : theImage.height + 20
});
});
These function doesn't work all time. Often the resize image is very small. I don't have any idea to fix it.
Here is a sample gallery www.phyxius.de/projects/phx.imga/