3
我使用引導傳送帶作爲圖像庫系統,在查看普通相冊(如200張或更少圖像)時效果很好。然而,該網站的所有者試圖添加一張擁有1472張圖片的專輯......這顯然完全讓系統崩潰,因爲它一次載入所有這些圖片。Bootstrap輪播問題 - 僅在查看時才加載圖像?
有沒有辦法只在下一個按鈕被點擊時加載下面的圖片?在單次裝載時,何時需要?或者如果沒有 - 關於如何加速這個系統的一些想法或建議?我寧願沒有整個頁面重新加載每一次,只有圖像。
這裏是我使用的是當前的腳本:
<?
if(!$select_first == ''){
$sql = "SELECT * FROM `new_images` WHERE `alb_ref` = '$alb_ref' AND full_link < '$select_first' ORDER BY full_link ASC";
$result = $conn->query($sql);
if ($result->num_rows > 0) {
while($row = $result->fetch_assoc()) {
$image_id = $row['img_id'];
$thumb_link = $row['thumb_link'];
$full_link = $row['full_link'];
if (!file_exists($full_link)) {
$full_link = 'img/default_img.jpg';
}
$viewed_count = $row['viewed_count'];
$date_added = $row['date_added'];
$i++;
$reback = $reback - 1;
?>
<div class="item <? if($i == 1){ echo 'active'; } else { } ?>">
<!-- Set the first background image using inline CSS below. -->
<div class="fill"><img class="img-responsive" style="max-width: 100%; max-height: 80%; display: block; margin: 0 auto;" src="<? echo $full_link; ?>" alt="image"></div>
<div class="carousel-caption">
<h2>
<form action="<? echo $_SERVER['PHP_SELF']; ?>" method="post" target="_top">
<input type="hidden" id="image_selected" name="image_selected" value="<? echo $full_link; ?>">
<?
$getPhotoinfo = mysqli_fetch_assoc(mysqli_query($conn, "SELECT album_name, venue_name, city_name FROM new_albums WHERE album_ref = '$alb_ref'"));
$photo_album_name = $getPhotoinfo['album_name'];
$photo_venue_name = $getPhotoinfo['venue_name'];
$photo_city_name = $getPhotoinfo['city_name'];
$sharelink = $main_website_domain.'/'.$full_link;
$sharedesc = '';
?>
<div class="btn-group">
<button type="button" class="btn btn-primary dropdown-toggle" data-toggle="dropdown">
<i class="fa fa-share" aria-hidden="true"></i> Share <span class="caret caret-up"></span>
</button>
<ul class="dropdown-menu drop-up" role="menu">
<li><a href="#" onclick="postImage('<?php echo $sharelink ?>', '<?php echo $sharedesc ?>')"><i class="fa fa-facebook-square" aria-hidden="true" style="color:#06C"></i> Post to Facebook</a></li>
<li><a href="send_email.php?image=<? echo $image_id; ?>&backalbum=<? echo $alb_ref; ?>" target="_top"><i class="fa fa-envelope-o" aria-hidden="true" style="color:#939"></i> Send as Email</a></li>
<li><a href="user_favourites.php?save=<? echo $image_id; ?>&backalbum=<? echo $alb_ref; ?>" target="_top"><i class="fa fa-floppy-o" aria-hidden="true" style="color:#090"></i> Save as Favourite</a></li>
<li class="divider"></li>
<li><a href="report_image.php?report=<? echo $image_id; ?>&backalbum=<? echo $alb_ref; ?>" target="_top"><i class="fa fa-flag" aria-hidden="true" style="color:#F00"></i> Report Photo</a></li>
</ul>
</div>
<button type="submit" id="download" name="download" class="btn btn-success"><i class="fa fa-download" aria-hidden="true"></i> Download</button>
<a href="album.php?alb_ref=<? echo $alb_ref; ?>" class="btn btn-default" target="_top"><i class="fa fa-chevron-circle-left" aria-hidden="true"></i> Back</a>
</form>
</h2>
<p style="color:#666">Image <? echo $starter - $reback; ?>/<? echo $rowcount_total_images; ?></p>
</div>
</div>
<?
}
}
}
?>
</div>
<!-- Controls -->
<a class="left carousel-control" href="#myCarousel" data-slide="prev">
<span class="icon-prev" style="color:#03C; font-size:70px;"></span>
</a>
<a class="right carousel-control" href="#myCarousel" data-slide="next">
<span class="icon-next" style="color:#03C; font-size:70px;"></span>
</a>
</header>
http://stackoverflow.com/questions/27675968/lazy-load-not-work-in-bootstrap-carousel可能會幫助您,將延遲加載添加到你的旋轉木馬。 – Epodax
結帳http://getbootstrap.com/javascript/#carousel-events –