Differences

This shows you the differences between two versions of the page.

Link to this comparison view

jf_webbutv10 [2017-09-01 14:54]
jf_webbutv10 [2022-07-18 13:20] (current)
Line 1: Line 1:
 +====== Hämta alla bilder i en mapp med glob ======
 +<code php>
 +<!DOCTYPE html>
 +<html lang="sv">
 +<head>
 +<meta charset="utf-8">
 +<link rel="stylesheet" href="fotogalleri.css">
 +<title>Foto Galleri</title>
 +</head>
 +<body>
 +<?php
 +$pics = glob('pics/*.jpg');
 +shuffle($pics);
 +$i=0;
 +foreach ($pics as $pic) {
 +  $i++;
 +  $imageinfo = getimagesize($pic);
 +  echo '<div class="box"  tabindex="'.$i.'">
 +          <div title="' . basename($pic,'.jpg') .'">
 +            <img src="' . $pic . '" alt="' . basename($pic,'.jpg') . '" width="' . $imageinfo[0]/2 . '" height="' . $imageinfo[1]/2 . '">
 +          </div>
 +        </div>';
 +}
 +?>
 +</body>
 +</html>
  
 +</code>