【发布时间】:2015-07-17 09:44:34
【问题描述】:
所以我正在尝试合并 LightBox 插件以便弹出图像:LightBox Info
但是,我的 php 代码使用 img 标签而不是 a 标签,因为 Lightbox 如此需要。当我尝试它时,似乎 href 和 src 冲突。图像和所有内容都正确显示,只需将 LightBox 与我的代码一起使用即可。我想知道是否有人知道该怎么做。
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<script src="/var/www/html/jquery-1.11.3.min.js"></script>
<script src="/var/www/lightbox2-master/dist/js/lightbox.js"></script>
<title>Greeting Cards</title>
<link rel="icon" type="image/png" href="../../favicon-32x32.png" sizes="32x32" />
<link rel="icon" type="image/png" href="../../favicon-16x16.png" sizes="16x16" />
<link rel="icon" type="image/x-icon" href="../../chromevers.ico" />
<link rel="stylesheet" type="text/css" href="../../styles/catbar.css">
<link rel="stylesheet" href="/var/www/lightbox2-master/dist/css/lightbox.css">
</head>
<body>
<?php
include '/var/db_file.php';
include '/var/www/WideImage/lib/WideImage.php';
$con = mysqli_connect($theDb,$usr, $pass, "images");
mysqli_select_db($con, "images");
$query = "SELECT * FROM Greeting_Cards";
$result = mysqli_query($con, $query);
$images = array();
while($row = mysqli_fetch_assoc($result)){
$images[] = $row['image'];
}
echo '<div id ="gallery">';
foreach ($images as $image) {
$image = WideImage::loadFromString($image)->resize(300, 300);
echo '<img id="database" src="data:image/jpeg;base64,'. base64_encode($image) .'" />';
}
echo '</div>';
mysqli_close($con);
?>
</body>
</html>
谢谢!
【问题讨论】:
-
看起来您没有包含 lightblox.js ?必须尝试将您的 img 更改为 a's 吗? 图片#1
-
检查你的控制台显示什么错误???
-
我搞错了!也萨蒂,没有错误出现。对 js 和 css 文件的调用现在应该是有序的。而且我不知道如何对不在文件系统上的图像进行href。就像我之前提到的,图像是从 mysql 数据库中获取的。
-
随机我不能这样做,因为我没有硬链接可以参考,因为信息存储在 mysql 数据库中,这就是这个问题的全部原因。
-
你有解决办法吗?