Keyword

Image display order

  • gwilym
  • gwilym's Avatar Topic Author
  • Offline
  • New Member
More
17 years 5 months ago #4967 by gwilym
Image display order was created by gwilym
Hi there - is it possible to change a setting so the images are displayed with the most recent image (by creation date of file) showing first?

Many thanks,

Gwilym

Please Log in or Create an account to join the conversation.

  • JoomlaWorks Support Team
  • JoomlaWorks Support Team's Avatar
  • Offline
  • Platinum Member
More
17 years 4 months ago - 17 years 4 months ago #4968 by JoomlaWorks Support Team
Replied by JoomlaWorks Support Team on topic Re: Image display order
Hi there!

well, lets try this.

at the file plugin_jw_sig.php go to the line 50

chenge the code
$images[] = array('filename' => $f);
to
$images[] = array('filename' => $f, 'filemtime' => filemtime($mosConfig_absolute_path.$rootfolder.$_images_dir_."/".$f));

after that, add the next code after the if block of the opendir
foreach ($images as $key => $value) {
   $filemtime[$key]  = $value['filemtime'];
}
array_multisort($filemtime, SORT_DESC, $images);

Try it and come back to tell me if work for you!

At my tests on my pc work!  ;)

The Code
// read directory
if ($dh = opendir($mosConfig_absolute_path.$rootfolder.$_images_dir_)) {
 while (($f = readdir($dh)) !== false) {
  if((substr(strtolower($f),-3) == 'jpg') || (substr(strtolower($f),-3) == 'gif') || (substr(strtolower($f),-3) == 'png')) {
   $noimage++;
   $images[] = array('filename' => $f, 'filemtime' => filemtime($mosConfig_absolute_path.$rootfolder.$_images_dir_."/".$f));
  }
 }
 closedir($dh);
}
        
foreach ($images as $key => $value) {
 $filemtime[$key]  = $value['filemtime'];
}
array_multisort($filemtime, SORT_DESC, $images);

JoomlaWorks Support Team
---
Please search the forum before posting a new topic :)

Please Log in or Create an account to join the conversation.


Powered by Kunena Forum