I have implemented a new tag in any post…

The tag <gallery>AlbumID|Count|Size</gallery> !

This in conjunction with the “psnGallery.php” addon allows you to display within a post “Count” random pictures from the Coppermine Album “AlbumID” in the “Size” (1= small, 2=normal).

For example, to get 4 random small pictures from the Album 6 (Boussole), the following command <gallery>6|4|1</gallery> will give :

Easy no ? In my-hacks.php, you have to add…

Of course, you need “psnGallery.php” to use “the_Random_picture()” function and you need to have a Coppermine Gallery installed !

function run_gallery($data) {
$backupdata = $data;

if(false !== strpos($data, "<gallery>") ) {
$data = str_replace(array("rn","r"), "n", $data);
while (false !== strpos($data, "<gallery>")) {
$BeforeGallery= substr($data, 0, strpos($data, "<gallery>")-1);
$AfterGallery = substr($data, strpos($data, "</gallery>")+10);
$GalleryTag = substr($data, strpos($data, "<gallery>")+9);
$GalleryTag = substr($GalleryTag,0,strpos($GalleryTag, "</gallery>")-1);
$elems = explode("|", $GalleryTag);
ob_start(); // run that data and grab what comes out
$data = $BeforeGallery.ob_get_clean().$AfterGallery;
} else {
$data = $backupdata;
return $data;

add_filter('the_content', 'run_gallery');

Comments are closed, but trackbacks and pingbacks are open.