Jump to content


Welcome to DevFuse Forums


Sign In  Log in with Facebook

Create Account
Welcome to DevFuse Forums, like most online communities you must register to view or post in our community, but don't worry this is a simple free process that requires minimal information for you to signup. Be apart of DevFuse Forums by signing in or creating an account.
  • Start new topics and reply to others
  • Subscribe to topics and forums to get email updates
  • Get your own profile page and make new friends
  • Send personal messages to other members.
 
Guest Message by DevFuse

Tutorial info Visit support topic

  • Added on: Jun 05 2011 07:32 AM
  • Views: 1613
 


Gallery 4.x Recent Image Adjustment

How to adjust the default number of images displayed and change their ordering to random.

Posted by AndyF on Jun 05 2011 07:32 AM
Quite often, a forum administrator will want to adjust the number of recent Gallery images shown on the board index. There is already an article on doing this on 3.x but as 4.x is completely different rather than add to that I felt a new article was best. :)

We are working with just one file so connect via FTP or your hosts file manager and open /admin/applications_addon/ips/gallery/sources/classes/hooks.php

Around line 82, find...
$recents = $this->registry->gallery->helper('image')->fetchImages( $this->memberData['member_id'], array( 'limit' => 20, 'sortKey' => 'date', 'sortOrder' => 'desc', 'unixCutOff' => GALLERY_A_YEAR_AGO ) );

Change the 20 to what you want, here's ten for an example:

$recents = $this->registry->gallery->helper('image')->fetchImages( $this->memberData['member_id'], array( 'limit' => 10, 'sortKey' => 'date', 'sortOrder' => 'desc', 'unixCutOff' => GALLERY_A_YEAR_AGO ) );


Some administrators may also prefer random images instead of the last uploaded as this is quite a popular change and adds a bit of variety too, especially for Galleries that are not heavily used. This again is very easy to achieve. :) , the same line needs adjusting for its 'sortKey' and optionally the 'sortOrder' removing. Here is the default of twenty images but random:

$recents = $this->registry->gallery->helper('image')->fetchImages( $this->memberData['member_id'], array( 'limit' => 20, 'sortKey' => 'rand', 'unixCutOff' => GALLERY_A_YEAR_AGO ) );

And here is ten images, again random:

$recents = $this->registry->gallery->helper('image')->fetchImages( $this->memberData['member_id'], array( 'limit' => 10, 'sortKey' => 'rand', 'unixCutOff' => GALLERY_A_YEAR_AGO ) );


Save the change / re-upload the file and you're done.

Powered by Tutorials 1.5.1 © 2016, by Michael McCune