Gallery2:Modules:refine - Gallery Codex
Personal tools


From Gallery Codex

HTML Refine Module
Refines Gallery2 HTML output and caches the result if required
Author: Dayo Akanji
Download the module files here.
Visit the Support Site for enquiries and support requests.


  • This module allows the Administrator to refine Gallery2 HTML output (strip out white space, prettify or minify).
  • It is derived from work done for gallery3 by Niklas Dougherty as set out in this forum post
  • Niklas Dougherty's work was based on the WP-Beautify plugin for wordpress by Till Krüss


  • Gallery2 (v2.3.0 and above)


The package contains two zip files: and The installation steps required are:

  • Unpack into the gallery2 "lib" folder

Around Line 100 of gallery2/main.php is ...

function GalleryMain($embedded=false) {

global $gallery;

Add the following lines after:

/* Added Event: BeforeProcess */
include(dirname(__FILE__) . '/lib/events/Gallery_BeforeProcess.event');

Around Line 530 of gallery2/main.php is ...

* Session: Find out whether we need to send a cookie & need a new session (only if
* we don't have one yet)
$session =& $gallery->getSession();
$ret = $session->start();
if ($ret) {
return array($ret, null);

Add the following lines after:

/* Added Event: BeforeOutput */
include(dirname(__FILE__) . '/lib/events/Gallery_BeforeOutput.event');

  • Unpack into the Gallery2 modules folder.
  • Install, configure and activate in the admin interface.


  • This module cannot be activated if either the JoomG2 or G2Drupal modules are active