Displaying Images inside a folder, but is it possible to link?

Asked

Viewed 39 times

0

I have a code in PHP, which displays all the images of a certain folder, but I wonder if it is possible to LINK with a <a href="link"></a> each image(knowing the order) determining a sequence in the code or similar to this. Does anyone have any idea or examples from the code below?

<?php
$pasta = 'img/img_anuncios/';

$arquivos = glob("$pasta{*.jpg,*.png,*.gif,*.bmp}", GLOB_BRACE);
foreach($arquivos as $img){?>
<a target="_blank" href="<?php echo $img; ?>" id="example1"><img class="mySlides w3-animate-fading" src="<?php echo $img; ?>" id="teste1"  style="width: 250px; height: 220px;"/></a>
<?php  }

?>

EDIT:

SOMETHING SIMILAR TO THIS (HTML):

<a target="_blank" href="LINK" ><img class="mySlides w3-animate-fading" src="img/calcemp_nova.png" id="teste1" style="width: 250px; height: 220px;"></a>
<a target="_blank" href="LINK" ><img class="mySlides w3-animate-fading" src="img/cohncor.png" id="teste1" style="width: 250px; height: 220px;"></a>
<a target="_blank" href="LINK" ><img class="mySlides w3-animate-fading" src="img/indemp_nova.png" id="teste1" style="width: 250px; height: 220px;"></a>
  • The way she’s not linking?

  • Yes, the link image. I wondered if it is possible to make a "private link" for each image, instead of creating one for each one in html.

  • I could not understand what you want to do. It has how to put an example of HTML that should be generated from this logic?

  • editei, put HTML. In this case I need to keep adding each line.

  • But your code doesn’t exactly generate this HTML that you’ve placed?

  • Yes, it does. I don’t think I can explain it. I’ll try to simplify it. It is possible to link the images by directing to an external link ( each image), instead of linking to the image itself in the PHP code above?

Show 1 more comment
No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.