Jump to content
DevFuse Forums
Sign in to follow this  

Gallery 4.x Recent Image Adjustment


How to adjust the default number of images displayed and change their ordering to random.
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...
[code]$recents = $this->registry->gallery->helper('image')->fetchImages( $this->memberData['member_id'], array( 'limit' => 20, 'sortKey' => 'date', 'sortOrder' => 'desc', 'unixCutOff' => GALLERY_A_YEAR_AGO ) );[/code]

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

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

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:

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

And here is ten images, again random:

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

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

Recommended Comments

There are no comments to display.