Recursive Image Viewer

Recursive Image Viewer If you have ever wanted to see all the images in your files directory or from a package that contains multiple directories, each with multiple images or subdirectories that may or may not contain images more images then this may help you. 

سوق الاسهم الكويت

الطريقة الأسهل لصنع المال على الإنترنت This is a very simple script that recursively scans a directory for images and then makes a HTML page displaying all these images on a single page to make browsing as easy as possible. To save your browser from crashing the images are lazy loaded as you scroll down and to fit as many on the page as possible there is a max width set on each image and I am using CSS Flex to give a little order to the chaos. 

طرق جيدة لكسب المال كطفل what is forex Each image box contains a 300px (max) wide image linking to the original in a new tab so that you do not have to reload the generated list. There is also some meta data about the image included. 

انتقل إلى هذا الموقع

تحليل سوق الخيارات الثنائية Bear in mind this is a fairly intensive script to run as it loads each file in the directory and checks to see if it is an image before building the HTML so if you are running it on a directory with 1000's of files it will take a little while to complete the scan, running it on the root of your live site is not a good idea but it can be extremely useful when you are searching for that image you edited last year! 

معلومات إضافية

لماذا لا معرفة المزيد As this was never intended to be a Drupal tool it assumes that it is a stand alone application and that you may want to use it just to look at images so having set it up as a site on your server any directories that you place within the docroot will automatically be linked from the home page so you can easily navigate to a page to scan the new directory of images your marketing team just asked you to look at. Check it out on GitHub And here's the code: 


كيف تربح الأموال في المملكة التحدة على الإنترنت <?php   /** * Recursively scans a directory and returns an array of the images within * * This can be used as a stand alone application for viewing images or if you * are a web developer you can put this in the root of your site and easily * ahve a way to search all the images on your site from one page. * * @global array $types * The image types to look for * @param string $dir * The directory to scan * @param array $images * An array to hold the images * * @return array * The Images */ function get_images_recursive($dir, $images = array()) { global $types;   // filetypes to display $types = array("jpeg", "jpg", "gif", "png");   // add trailing slash if missing if (substr($dir, -1) != "/") { $dir .= "/"; }   $d = dir($dir) or die("get_images_recursive: Failed opening directory $dir for reading");   while (false !== ($item = $d->read())) { // skip hidden files if ($item[0] == ".") { continue; }   if (is_dir($dir . $item) && isset($_GET['all'])) { $this_dir = get_images_recursive($dir . $item); $images = array_merge($images, $this_dir); }   // check for image files $path = $dir . $item; $mimetype = pathinfo($path, PATHINFO_EXTENSION);   if (in_array(strtolower($mimetype), $types)) { $images[] = array( 'path' => $path, 'file' => "/" . $dir . $item, 'size' => getimagesize($dir . $item) ); } } $d->close();   return $images;   } ?> <!DOCTYPE html> <html> <head> <title>All The Things</title> <script src="jquery-1.11.3.min.js"></script> <script src="jquery.lazyload.js"></script> <style type="text/css"> .container { display: flex; flex-wrap: wrap; } img { max-width: 300px; } .photo { max-width: 300px; margin: 12px; border: 1px solid #ccc; padding: 25px; font-size: 14px; } a{ color:#4183c4; text-decoration:none; outline:none; } a:hover{ text-decoration:underline; } a:active{ outline:none; } </style> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width"> </head> <body> <div class="container"> <?php $output = NULL; if (!empty($_GET['dir'])) {   $dir = $_GET['dir']; // add trailing slash if missing if (substr($dir, -1) != "/") { $dir .= "/"; }   $d = dir($dir) or die("get_images_recursive: Failed opening directory $dir for reading"); $output .= "<ul>"; while (false !== ($item = $d->read())) { // skip hidden files if ($item[0] == ".") { continue; } if (is_dir($dir . $item)) { $output .= "<li><a href=\"?dir=$dir$item\">images from /$dir$item</a></li>"; } } $output .= "</ul>";   // fetch image details $images = get_images_recursive($dir);   $ratio = 0.3; foreach ($images as $img) { $width = $img['size'][0] * $ratio; $height = $img['size'][1] * $ratio;   // If you want to set the width and height in code delete the // img class above in the CSS and add the following line to the image tag // width=\"{$width}\" height=\"{$height}\"   $output .= "<div class=\"photo\">"; $output .= "<a target=\"_blank\" href=\"{$img['path']}\">"; $output .= "<img class=\"lazy\" data-original=\"{$img['path']}\" alt=\"\"></a><br>\n"; // display image file name as link $output .= "<a target=\"_blank\" href=\"{$img['path']}\">" . basename($img['file']) . "</a><br>\n"; // display image dimenstions $output .= "({$img['size'][0]} x {$img['size'][1]} pixels)<br>\n"; // display mime_type $output .= $img['size']['mime']; $output .= "</div>\n"; } } // Link to the directories else { $d = dir(__DIR__ . '/' . $dir) or die("get_images_recursive: Failed opening directory " . __DIR__ . '/' . $dir . " for reading"); $output .= "<ul>"; while (false !== ($item = $d->read())) { // skip hidden files if ($item[0] == ".") { continue; } if (is_dir($dir . $item)) { $output .= "<li><a href=\"?dir=$item\">images from /$item</a></li>"; } } $output .= "</ul>"; }   $output = str_replace('<ul></ul>', '', $output); if (!empty($output)) { print $output; } ?> </div> <script type="text/javascript" charset="utf-8"> $(function () { $("img.lazy").lazyload(); }); </script> </body> </html>


Plain text

  • No HTML tags allowed.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.
By submitting this form, you accept the Mollom privacy policy.