gpt4 book ai didi

php - 使用 PHP 时出现 FancyBox 错误。有任何想法吗?

转载 作者:太空宇宙 更新时间:2023-11-04 00:08:49 25 4
gpt4 key购买 nike

只是想分享我的代码,看看是否有人能找出导致此问题的原因。

错误如下:“无法加载请求的内容。请稍后再试。”

ShowAll.PHP:

    <?
include_once "db.php";
session_start();
$gid=$_SESSION['gid'];
$result = mysql_query("SELECT id,groupid FROM images where gid='".$gid."' and imagetype='1' ORDER BY id");
print(" <div id='wrapper'>
<!--start: Container -->
<div class='container'>
");
$j=0;
print("
<div class='row'>
<div class='span6'>
<h1>My Gallery</h1>
<br>
</div>
<div class='span6'>
</div>
</div>
<!--start: Row -->
<div class='row'>");
while($row = mysql_fetch_array($result)){
if ($j==6){
$j=0;
print("</div>");
print("
<!--start: Row -->
<div class='row'>");
print("<div class='span2'>");
print("<p><div class='picture'><a rel='image' href='largeimage.php?groupid=".$row['groupid']."'><img src='showimage.php?id=".$row['id']."'><div class='image-overlay-zoom'></div></a></div>");
print("</div>");
$j++;
}else{
print("<div class='span2'>");
print("<p><div class='picture'><a rel='image' href='largeimage.php?groupid=".$row['groupid']."'><img src='showimage.php?id=".$row['id']."'><div class='image-overlay-zoom'></div></a></div>");
print("</div>");
$j++;
}
}
print("</div>");?>

largeimage.php:

<?php

$groupid=$_GET['groupid'];


print(" <img src='showimagelarge.php?groupid=".$groupid."'>");

?>

showimagelarge.php:

include_once "db.php";

session_start();



$gid=$_SESSION['gid'];

header('Content-type: image/jpeg');

$query = "SELECT image from images where groupid=". intval($_GET["groupid"])." and gid='".$gid."' and imagetype='2'";

$rs = mysql_fetch_array(mysql_query($query));

echo base64_decode($rs["image"]);

?>

showimage.php:

include_once "db.php";

session_start();



$gid=$_SESSION['gid'];

header('Content-type: image/jpeg');

$query = "SELECT image from images where id=". intval($_GET["id"])." and gid='".$gid."'";

$rs = mysql_fetch_array(mysql_query($query));

echo base64_decode($rs["image"]);

?>

最佳答案

您正在以这种方式呈现指向图像的链接:

<div class='picture'><a rel='image' href='largeimage.php?groupid=".$row['groupid']."'>....

... 所以您的链接 href 将没有任何图像扩展名(jpg、png、gif)。因为那个 fancybox 不知道要处理什么type 的内容,因此消息

The requested content cannot be loaded. Please try again later.

您需要在您的 fancybox 自定义脚本中将内容的 type 强制设置为 image。这记录在这里 http://fancyapps.com/fancybox/#support , FAQ 选项卡 No. 5

您可以执行以下任一操作:

<script type="text/javascript">
$(document).ready(function(){
$(".picture a").fancybox({
"type": "image"
});
});
</script>

...或者

<script type="text/javascript">
$(document).ready(function(){
$('a[rel="image"]').fancybox({
"type": "image"
});
});
</script>

关于php - 使用 PHP 时出现 FancyBox 错误。有任何想法吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13850218/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com