Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Displaying images in descending order #9

Open
TuulikkiLaine opened this issue Feb 23, 2015 · 1 comment
Open

Displaying images in descending order #9

TuulikkiLaine opened this issue Feb 23, 2015 · 1 comment

Comments

@TuulikkiLaine
Copy link

Is it possible to get elements in descending order, as in - if more elements are added (with higher id), they would be prepended to the gallery and shown first? What would be the easiest way to do this? Thanks a lot!

@Bigben83
Copy link

This is the script I use to scan a dir and list images in it. it also extracts data from the exif of the file. but you can delete this if you need.

`<?php
$client = (isset($_GET["client"])) ? $_GET["client"] : ""; // client number

$directory = "directory";
$dirname = $directory . "/" . $client . "/";
$images = scandir($dirname);
//shuffle($images);
rsort($images);
$ignore = array(".", "..");
foreach($images as $curimg){
	if(!in_array($curimg, $ignore)) {
	    
	    $currimage= "$dirname$curimg";
	    
	    
	    //Gets file name
	    $filename = basename($currimage);
	    $author = substr($filename, 0, strpos($filename, '.', strpos($filename, '.')+1));
	        $author = str_replace('.', ' ', $author); 
	    $date = substr($filename, 0, strpos($filename, '.', strpos($filename, '.')+1));
	    $title = $author;
	    
	    if(mime_content_type($currimage)=='video/mp4'){
            $currimage = $currimage;
	    }else{
            // read all available tags into an associative array
            $exif_ifd0 = read_exif_data($currimage ,'IFD0' ,0);
            $exif_data = exif_read_data($currimage ,'EXIF' ,0);
            //error control
            $notFound = "Unavailable";
            
            // Date
              if (@array_key_exists('DateTime', $exif_ifd0)) {
                $camDate = $exif_ifd0['DateTime'];
              } else { $camDate = $notFound; }
            // Exposure
              if (@array_key_exists('ExposureTime', $exif_ifd0)) {
                $camExposure = $exif_ifd0['ExposureTime'];
              } else { $camExposure = $notFound; }
            // Aperture
              if (@array_key_exists('ApertureFNumber', $exif_ifd0['COMPUTED'])) {
                $camAperture = $exif_ifd0['COMPUTED']['ApertureFNumber'];
              } else { $camAperture = $notFound; }
            // ISO
              if (@array_key_exists('ISOSpeedRatings',$exif_exif)) {
                $camIso = $exif_exif['ISOSpeedRatings'];
              } else { $camIso = $notFound; }
	    }
	    
		// Type contains video/mp4,video/avi,video/mpeg,video/mpg etc
        if(preg_match('/video\/*/',$currimage)){
            echo "<li>
                <div data-alt=\"$title\" data-description=\"<h3>$title</h3><h4>$date</h4>\" data-max-width=\"1800\" data-max-height=\"1350\">
                    <video width=\"700\" height=\"450\" preload=\"true\">
                        <source src=\"$currimage\" type=\"video/mov\">
                        <source src=\"$currimage\" type=\"video/mp4\">
                        <source src=\"$currimage\" type=\"video/oog\">
                        Your browser does not support the video tag.
                    </video>
                </div>
            </li>";
        }else{
		    //echo "<li><a href=\"$dirname$curimg\"><img src='img.php?src=$dirname$curimg&w=300&zc=1' alt='' /></a></li>\n ";
			echo "<li>
                    <div data-alt=\"$title\" data-description=\"<h3>$title</h3><h4>$date</h4>\" data-max-width=\"1800\" data-max-height=\"1350\">
                    <div data-src=\"$currimage\" data-min-width=\"1300\"></div>
                    <div data-src=\"$currimage\" data-min-width=\"1000\"></div>
                    <div data-src=\"$currimage\" data-min-width=\"700\"></div>
                    <div data-src=\"$currimage\" data-min-width=\"300\"></div>
                    <div data-src=\"$currimage\" data-min-width=\"200\"></div>
                    <div data-src=\"$currimage\" data-min-width=\"140\"></div>
                    <div data-src=\"$currimage\"></div>
                        <noscript><img src=\"$currimage\" alt=\"<h3>$title</h3>\"/></noscript>
                    </div>
                </li>"; 
        };
	}
}`

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants