简体   繁体   English

PHP A将缩略图超链接到其他图像

[英]PHP A hyperlinks thumbnails to other images

Here's my php: 这是我的PHP:

    $thumbs  = glob('images/*_thumb.jpg');
    $thumbs_number = count($thumbs);
    $watermarked = glob('images/*_watermarked.jpg');
    $watermarked_number = count($znaki);
    for ($i = 0; $i < $thumbs_number; $i++) {
    echo "<img src='$thumbs[$i]' hspace='20' />";
    }

I am currently displaying the thumbnails of uploaded images stored in folder images. 我目前正在显示存储在文件夹图像中的上传图像的缩略图。 What I'm looking for is a way to link them to watermarked images of uploaded files. 我正在寻找一种将它们链接到上传文件的水印图像的方法。

In folder images I have 3 files: 在文件夹图像中,我有3个文件:

1.jpg, 1.jpg_thumb.jpg, 1.jpg_watermarked.jpg. 1.jpg,1.jpg_thumb.jpg,1.jpg_watermarked.jpg。

So if I click the the thumbnails, it should open an watermarked image of uploaded file. 因此,如果单击缩略图,则应该打开上传文件的水印图像。 How to do it? 怎么做?

This is not actually a PHP question but an HTML question. 这实际上不是PHP问题,而是HTML问题。 Simply pack the img tag in an anchor tag that links to the watermarked picture. 只需将img标签包装到链接到带水印图片的锚标签中即可。

EDIT: OP requested specific code so here you go: 编辑:OP请求特定的代码,所以你去:

echo "<a href='{$watermarked[$i]}'><img src='{$thumbs[$i]}' hspace='20' alt='Picture'/></a>";

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM