我使用 Highslide jQuery Gallery 在单个页面上加载专辑及其缩略图。用户可以单击缩略图,然后加载每个相册。
如果我每页有超过 10 个相册(由于加载拇指和图片),网站运行速度很慢,我对数据库中的数据使用 base64 编码。
如何仅加载缩略图而不是整个专辑?仅当用户单击缩略图后,相册才会加载。
<?php
//vars
$albumsQuery = mysql_query("select * from albums");
$album_count = 0;
// start loop
while ($album = mysql_fetch_array($albumsQuery)) {
$album_count++;
$unserializePhotos = unserialize(base64_decode($album['photos']));
$unserializeDescriptions = unserialize(base64_decode($album['descriptions']));
$firstPhoto = '';
$first_photo_count = 0;
foreach ($unserializePhotos as $k => $v) {
if ($first_photo_count == 0) {
$firstPhoto = $v['name'];
}
$first_photo_count++;
}
$first_desc_count = 0;
foreach ($unserializeDescriptions as $k => $v) {
$unserializeDescriptions[$k]=htmlspecialchars($v);
if ($first_desc_count == 0) {
$firstDesc = htmlspecialchars($v);
}
$first_desc_count++;
}
?>
<div class="highslide-gallery">
<a class='highslide' id="thumb<?php echo $album_count; ?>" href='/albums/<?php echo $firstPhoto; ?>' onclick="return hs.expand(this, {slideshowGroup: <?php echo $album_count; ?>})">
<img src='/albums/<?php echo $firstPhoto; ?>' height="100px" width="100px" />
</a>
<div class="hidden-container">
<?php
$photoDescIndex = 0;
foreach ($unserializePhotos as $k => $v) {
if ($v['name'] != '' && $v['name'] != $firstPhoto){
?>
<a class='highslide' href='/albums/<?php echo $v['name']; ?>' onclick="return hs.expand(this, {slideshowGroup: <?php echo $album_count; ?>})">
<img src='/albums/<?php echo $v['name']; ?>' />
</a>
<?php
}
$photoDescIndex++;
}
?>
</div>