如何在同一页面打开图片?
我有一个相册插件(php),它可以在一页中为我的图像创建缩略图,当我单击图像时,会在新页面中打开每个图像。
有没有办法在缩略图的同一页上打开图像?
这是我的缩略图代码:
<div class="thumbs">
<?php foreach (wppa_get_thumbs() as $tt) : global $thumb; $thumb = $tt; ?>
<a href="<?php wppa_photo_page_url(); ?>" class="img"><img src="<?php wppa_thumb_url(); ?>" alt="*" /></a>
<?php endforeach; ?>
</div>
这是特定照片的代码:
<?php } else if (wppa_page('single')) { // if is showing a specific photo ?>
<a href="<?php wppa_photo_url(); ?>"><img src="<?php wppa_photo_url(); ?>" alt="<?php wppa_photo_name(); ?>" class="big" <?php echo wppa_get_fullsize(); ?> />
</a><br />
<?php } ?>
这是创建链接的函数:
// get link to photo
function wppa_photo_page_url($return = FALSE) {
global $thumb;
$url = get_permalink() . wppa_sep() . 'album=' . $_GET['album'] . '&photo=' . $thumb['id'];
if ($return) {
return $url;
} else {
echo $url;
}
}
我尝试删除链接代码但不起作用。
I have an album plugin (php) that creates thumbnails for my images in one page and when i click on images opens each image in a new page.
Is there a way to opening images on the same page of thumbnails?
This is my code of thumbnails:
<div class="thumbs">
<?php foreach (wppa_get_thumbs() as $tt) : global $thumb; $thumb = $tt; ?>
<a href="<?php wppa_photo_page_url(); ?>" class="img"><img src="<?php wppa_thumb_url(); ?>" alt="*" /></a>
<?php endforeach; ?>
</div>
and this is the code of specific photo:
<?php } else if (wppa_page('single')) { // if is showing a specific photo ?>
<a href="<?php wppa_photo_url(); ?>"><img src="<?php wppa_photo_url(); ?>" alt="<?php wppa_photo_name(); ?>" class="big" <?php echo wppa_get_fullsize(); ?> />
</a><br />
<?php } ?>
And this is the function that creates links:
// get link to photo
function wppa_photo_page_url($return = FALSE) {
global $thumb;
$url = get_permalink() . wppa_sep() . 'album=' . $_GET['album'] . '&photo=' . $thumb['id'];
if ($return) {
return $url;
} else {
echo $url;
}
}
I tried to remove the link code but does not work.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

发布评论
评论(3)
可遇━不可求2024-12-27 00:40:16
实际上,使用普通 javascript 的 Image
对象很容易做到。您可以有一个执行以下操作的函数:
function load_image(image_path)
{
var image = new Image();
image.src = image_path;
return image;
}
您可以从他们单击的链接中提取图像的 url。
然后,将该图像附加到您拥有的隐藏 div 中并使其可见。如果您使用的是 jQuery:
var image = load_image("/path/to/your/image.jpg");
$(image).appendTo("#your-image-div");
$("#your-image-div").show();
这尚未经过测试,但应该可以工作。
~没有更多了~
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
在新窗口中打开链接的行为通常与锚点的“目标”属性相关联。例如,这会将链接放入新窗口中:
但是您上面粘贴的代码似乎不包含 中的目标属性,因此我怀疑该行为是在您的 CSS 中控制的,而您没有将其包含在问题中。
检查您的 CSS 文件,并查找“目标”。 W3C 有已发布文档来描述其工作原理。
The act of opening a link in a new window is usually associated with the "target" attribute of an anchor. For example, this would put links in new windows:
But the code you've pasted above does not appear to include target attributes in , so I suspect the behaviour is controlled in your CSS, which you didn't include in your question.
Check your CSS files, and look for "target". The W3C has published documentation that describes how this works.