Topic: snippet portfolio
Looking for images and insert them into the web.
<!--[if gte IE 8]> <style type="text/css"> .port-img-ie{ width:100%; /* example for ie */ height:180px; /* example for ie */ } </style> <![endif]--> <table class=""> <tr> <?php $path = 'public/uploads'; # Directory Images $limit = 16; # How many images are displayed per page $limit_file = 4; # Pictures to show per line in the table $n = 0; $from; $to; // Check if a directory if (is_dir($path)){ $dir = opendir($path); while (false !== ($file = readdir($dir))) { if (preg_match("#([a-zA-Z0-9_\-\s]+)\.(gif|GIF|jpg|JPG|png|PNG)#is",$file)){ $list[] = $file; }} // close directory closedir($dir); // We order the list sort ($list); // Count the total items in list $total = count($list); $pages = ceil($total/$limit); if (!isset($_GET['pg'])){ $from = 0; $to = $from + $limit; }else if((int)$_GET['pg'] > ($pages-1)){ // If pg is greater than the total page displays an error echo "<b>No such product in the gallery</b>"; die(); }else{ $from = (int)$_GET['pg']; } // And generate links with thumbnails for ($i=($from*$limit);($i!=$total) && ($i<($from*$limit)+$limit);$i++){ // Check for a key in the list with the current value of $ i to avoid errors if(array_key_exists($i, $list)){ echo "<td> <img class='port-img-ie' src='$path/$list[$i]' /> </td>\n"; $n++; if ($n == $limit_file){ echo "</tr>\n"; $n = 0; }}} }else{ echo "$path not a directory"; } ?> </tr> </table>
Example.
http://nakome.16mb.com/portfolio
..::: Moncho Varela ::::.. ..::: @Nakome ::::.. ..::: Github ::::..