Jump to content

Short displayed images by date newer to older


Gozaro

Recommended Posts

I'm using the following function to read a directory and show images as a gallery, it works really well, but I need to display images ordering by date from newer to older.

Knows anyone how to do it using this method?

function getPictures() {


global $page, $per_page, $has_previous, $has_next;
if ( $handle = opendir("saved/2013") ) {
$lightbox = rand();

$count = 0;
$skip = $page * $per_page;


if ( $skip != 0 )
$has_previous = true;

while ( $count < $skip && ($file = readdir($handle)) !== false ) {
if ( !is_dir($file) && ($type = getPictureType($file)) != '' )
$count++;
}
$count = 0;
while ( $count < $per_page && ($file = readdir($handle)) !== false ) {
if ( !is_dir($file) && ($type = getPictureType($file)) != '' ) {
if ( ! is_dir('saved/2013') ) {
mkdir('saved/2013');
}


$strFileName = "saved/2013/".$file;
echo '<div id="imagen-t">';
echo '<p>' .date( "D d M Y g:i A", filemtime($strFileName)) . "</p>";
echo '<p><a href="saved/2013/'.$file.'" rel="lightbox['.$lightbox.']"><img src=saved/2013/'.$file.' alt="" width="220" /></a></p>';
echo '</div>';
$count++;
}
}


while ( ($file = readdir($handle)) !== false ) {
if ( !is_dir($file) && ($type = getPictureType($file)) != '' ) {
$has_next = true;
break;
}
}
}
}

Here is the code working http://www.espigoplatja.com/whale/galeria/

 

 

By the way another possible solution to start index.php with the end of the page in this case http://www.espigoplatja.com/whale/galeria/?page=15

 

Salutations,

Gonzalo

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.