PHP A hyperlinks thumbails to other images

Asked by At

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?

EDIT: Locercus answers were really helpful. Problem solved!

1 Answers

miestasmia On Best Solutions

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>";