phpimagehyperlinkdisplayobject

PHP A hyperlinks thumbnails to other images


Here's my 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:

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?


Solution

  • This is not actually a PHP question but an HTML question. Simply pack the img tag in an anchor tag that links to the watermarked picture.

    EDIT: OP requested specific code so here you go:

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