Php script question (accessing coppermine photos) Php script question (accessing coppermine photos)
 

News:

CPG Release 1.6.26
Correct PHP8.2 issues with user and language managers.
Additional fixes for PHP 8.2
Correct PHP8 error with SMF 2.0 bridge.
Correct IPTC supplimental category parsing.
Download and info HERE

Main Menu

Php script question (accessing coppermine photos)

Started by eris667, August 06, 2009, 08:34:04 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

eris667

This is not Directly a coppermine question . . .
I have the following PHP script I would like to use to access a coppermine gallery

<?
//http://www.reconn.us/random_file.html
$imglist='';
//$img_folder is the variable that holds the path to the banner images. Mine is images/tutorials/
// see that you don't forget about the "/" at the end
$img_folder = "RandomImages/";

mt_srand((double)microtime()*1000);

//use the directory class
$imgs = dir($img_folder);

//read all files from the directory, checks if are images and ads them to a list (see below how to display flash banners)
while ($file = $imgs->read()) {
if (eregi("gif", $file) || eregi("jpg", $file) || eregi("png", $file))
$imglist .= "$file ";

} closedir($imgs->handle);

//put all images into an array
$imglist = explode(" ", $imglist);
$no = sizeof($imglist)-2;

//generate a random number between 0 and the number of images
$random = mt_rand(0, $no);
$image = $imglist[$random];

//display image
echo '<img src="'.$img_folder.$image.'" border=0>';
?>

My question is how to modify the script to use only the uploaded image (not thumb_ ect.)
I am assuming their is some kind of logic I can use to eliminate the files based on the prefix - any suggestions?
I know I will have to change the path in $img_folder to a gallery. . .

I appreciate any feedback,

Mike

Nibbler

You'd probably be better off using cpmFetch. That's what it's for.

eris667

I will look into it, cpmFetch looks like a lot bigger program than I need :D
thanks for the advise !

Mike

Joachim Müller

Quote from: eris667 on August 06, 2009, 08:34:04 PMMy question is how to modify the script to use only the uploaded image (not thumb_ ect.)
You asked for the naming scheme of Coppermine, i.e. how to determine which files were created by coppermine, so here's the answer: the intermediate image and the thumbnail are being prefixed. The prefix can be configured, so this will not apply to all installs, but the default names will apply for most coppermine installs: normal_ is the prefix for intermediates and thumb_ is the prefix for thumbnails.
You would have to perform a string comparison. Sort out all files that are prefixed in a manner that you don't want.
Nibbler tried to be nice and not bash you, but quite frankly: your code leaves a lot of room for improvement ;). You should really look into the existing mods for content syndication, they are very easy to apply.

eris667

I was originally looking to do this a different way. . .
http://forum.coppermine-gallery.net/index.php?topic=61062.new;topicseen#new

but luckily the great people here pointed me in the right direction !

My End Result. . .
http://www.strm.us/cpg14x/index.php
or
http://www.strm.us/

Excellent Plugin work, great documentation.

Thank you,

Mike Praeuner
Bartlett, TN

Joachim Müller

and which plugin id you use then? Maybe you could post reference to it for the benefit of others and to credit the author. Merging with your original thread.

Joachim

P.S. cpmFetch is not a plugin, as it doesn't use coppermine's plugin API.

eris667

Sorry if I was not clear - I used CPMfetch (http://cpmfetch.fistfullofcode.com/)
I had posted here (http://forum.coppermine-gallery.net/index.php/board,87.0.html) in case the author monitored it, to say thank you.

The idea of CPMfetch being a plugin originally made me reluctant to try it out, but like you stated it is not a plugin, and it works great.

The documentation (http://cpmfetch.fistfullofcode.com/docs/index.php) is well worth the read, and very informative (including multiple examples)

Thank You for correcting me, and putting this post in a more useful place.

Mike