Je possède une galerie photo Coppermine et je désirais depuis quelque temps afficher des images aléatoire en provenance de cette galerie sur ce site.

Voici le script que je propose, à enregistrer sous le nom get_photo.php dans le même répertoire que votre galerie Coppermine. Ensuite si vous tapez http://magalerie.com/get_photo.php?album=1&nb=5 dans votre navigateur (adaptez à votre cas bien sûr) cela devrait vous afficher 5 photos aléatoire de l'album numéro 1. Si vous ne précisez pas nb le script affiche 4 images, et si vous ne précisez pas l'album, il affiche des images de n'importe quel album.

Ensuite sur la page ou vous voulez afficher une image aléatoire ajoutez à l'endroit ou vous voulez voir ces photos :

<?php $r=@file_get_contents("http://magalerie.com/get_photo.php?nb=1"); if ($r===false) { echo("Server down"); } else { echo $r;} ?>

Les images affichées sont de la classe get_photo si vous voulez personnaliser leur affichage avec une feuille de style CSS.

<?php 
// Coppermine Photo Gallery - get_image script
// Based on the RSS feed by Dr. Tarique Sani - http://tariquesani.net/
// Adapted by djib to display a random photo - http://djib.fr
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.
// -
// Just put into the same directory as your coppermine installation
// 

define('IN_COPPERMINE', true);
define('INDEX_PHP', true);
require('include/init.inc.php');

//How many items you want to show in your get_photo script
if(isset($_GET['nb'])) {
     $thumb_per_page=$_GET['nb'];
} else {
     $thumb_per_page = 4;
}
$thumb_count = 4;
$lower_limit = 0;

if(isset($_GET['album'])){
    $album = $_GET['album'];
}

//If it is a numeric album get the name and set variables
if (is_numeric($album)){
     $album_name_keyword = get_album_name($album);
     $CURRENT_CAT_NAME = $album_name_keyword['title'];
     $ALBUM_SET = "AND aid IN (".(int)$_GET['album'].")".$ALBUM_SET;
     $album = 'random';
}

//If the album is not set set it to lastup - this is the default
if(!isset($album)){
     $album = 'random';
}


//Changes these to point to your site if the following is not giving correct results.
$link_url = $CONFIG['ecards_more_pic_target']."displayimage.php?pos=-";
$image_url = $CONFIG['ecards_more_pic_target']."albums/";


$data = get_pic_data($album, $thumb_count, $album_name, $lower_limit, $thumb_per_page);


foreach($data AS $picture) {
    $thumb_url = "$image_url$picture[filepath]$CONFIG[thumb_pfx]$picture[filename]";
    $description = '<a href="' . $link_url . $picture['pid'] . '"><img class="get_photo" src="' . $thumb_url . '"  alt="Photo aléatoire"/></a>';
    echo $description;

}
?>