[显示带有法式长条框的数据库中的图像

问题描述 投票:0回答:1

我正在尝试使用baguetteBox.js从数据库中显示图像。问题是,baguetteBox可以与<a>标签一起使用,但是我却可以通过<img>标签来显示图像。我将它们插入mediumblob到我的数据库中,并且在任何文件夹中都没有它们。因此,这是工作中的法式长棍面包盒:

<div class="card-buttons">
<a href="1.jpg">
<div class="kepek">
<div class="btn-group mr-2" role="group" aria-label="Second group">
<button type="button" class="btn btn-primary">Képek</button>
</div>
</a>
<a href="2.jpg"></a>
</div>

这是工作图像列表:

<?php
$sql = "SELECT id FROM cardimages ORDER BY id DESC"; 
$result = mysqli_query($conn, $sql);
while($row = mysqli_fetch_array($result)) {
?>
<img src="imageView.php?image_id=<?php echo $row["id"]; ?>" /><br/>
<?php       
}
mysqli_close($conn);
?>

但是有了这个,我看不到任何图像:

<div class="card-buttons">
<a href="1.jpg">
<div class="kepek">
<div class="btn-group mr-2" role="group" aria-label="Second group">
<button type="button" class="btn btn-primary">Képek</button>
</div>
</a>
<a href="2.jpg"></a>
<?php
$sql = "SELECT id FROM cardimages ORDER BY id DESC"; 
$result = mysqli_query($conn, $sql);
while($row = mysqli_fetch_array($result)) {
?>
<a href="imageView.php?image_id=<?php echo $row["id"]; ?>"></a>

<?php       
}
mysqli_close($conn);
?>
</div>
javascript php
1个回答
0
投票

您需要在baguetteBox所需的<img>元素内使用<a>标签才能触发灯箱。链接元素将永远不会显示图像See the second example on their homepage

因此请在您的php文件中替换此行:

<a href="imageView.php?image_id=<?php echo $row["id"]; ?>"></a>

带有类似的内容(我假设您可能需要对其进行一些编辑)

<a href="imageView.php?image_id=<?php echo $row["id"]; ?>">
    <img src="imageView.php?image_id=<?php echo $row["id"]; ?>" />
</a>
© www.soinside.com 2019 - 2024. All rights reserved.