Everything works fine, the only problem is that it loads very slow. It takes 7 seconds to load a page containing 265 images. The images aren't on a remote server, and they are thumbnails. They are being displayed at true height/width as well, so the server doesn't have to resize them.
It shouldn't be the getimagesize(), because in a previous iteration of the page every image also had a getimagesize() function and that loaded without the problem.
The only thing I can find that could be a problem would be the database. This is the setup:
TABLE albums:
| id | naam | urlnaam | actief |
TABLE fotos:
| id | url | ext | description | albumid |
So the albumid from fotos is linked to the id from albums. Here's the code:
$album = mysql_real_escape_string($_GET['fx2']);
mysql_select_db('user_fotos');
$i = 0;
$sql = mysql_query("SELECT a.naam, b.url, b.ext, b.description, b.id FROM albums AS a LEFT JOIN fotos AS b ON a.id = b.albumid WHERE a.urlnaam = '$album'");
while($row = mysql_fetch_assoc($sql)){
if($i == 0){
echo "Album: {$row['naam']}<br />";
echo "<table><tr>";
}
if($i % 4 == 0){echo "</tr><tr>";}
echo "<td align='center'>";
$photourl = "http://www.mysite.com/fotos/$album/thumbs/" . $row['url'] . $row['ext'];
$dimensions = getimagesize($photourl);
$breedte = $dimensions[0];
$lengte = $dimensions[1];
if($breedte == '120'){$aspect="width='120px' height='{$lengte}px'";}else{$aspect="height='120px' width='{$breedte}px'";}
echo "<div class='imageHolder' style='width:{$breedte}px; height:{$lengte}px;' onClick=\"parent.location='$album/{$row['id']}'\" /><img $aspect src='http://www.mysite.com/fotos/$album/thumbs/" . $row['url'] . $row['ext'] . "' alt='{$row['description']}' /></div>";
echo "</td>";
$i++;
}
echo "</tr></table>";
getimagesize, it has to connect to that server and download those images over HTTP.style='width:{$breedte}px; height:{$lengte}px;'parts then the image would still be the original size without wasting time/resources/bandwidth checking the size, you should also cache the results & output.