Tutorial: Installing & Using Coppemine Fetch

Coppermine Fetch is a script used for displaying the latest images uploaded to your Coppermine Photo Gallery where-ever the code is displayed. It’s commonly used to display the latest images uploaded to your gallery in your header or sidebar.
In this tutorial you will learn how to install and use the script. Firstly, download a copy of CoppermineFetch from the Coppermine Official Forums.

installation

Extract the zip file on your computer and upload the folder called “cpmfetch” to your gallery’s directory. You want this folder to be in the same folder as your coppermine installation. (ie. gallery/cpmfetch/)
Next, run the installation file by going to your site where you uploaded cpmfetch and open the installer. (ie. yoursite.com/gallery/cpmfetch/install.php) You should see this page:

Now CPMFetch is installed!

Use

On the install page there are two codes, the first code is for using the script within the gallery folder, where as the second code is for using the script outside of your gallery folder. To display the latest images in wordpress, you want the second code that looks like this:
<?php
include "./gallery/cpmfetch/cpmfetch.php";
$objCpm = new cpm("./gallery/cpmfetch/cpmfetch_config.php");
$objCpm->cpm_viewLastAddedMedia(1,4);
$objCpm->cpm_close();
?>

IMPORTANT! if you have installed your gallery to a folder that is called something else like “photos” or “images” make sure you change the code to match your own directory name as CPMFetch doesn’t change this automatically.
To display the code in your sidebar, posts or pages, you’ll need to install a PHP execution plugin like PHP Everywhere in your WordPress Admin panel.
To customize the amount of images displayed you can change the numbers where is says “$objCpm->cpm_viewLastAddedMedia(1,4);” the first number is the amount of rows and the second number is the amount of images per row.
Additionally you can also add in the code to open clicked images in a new tab and the desired size of your images by adding an extra options line:
<?php
include "./gallery/cpmfetch/cpmfetch.php";
$objCpm = new cpm("./gallery/cpmfetch/cpmfetch_config.php");
$options = array(windowtarget => '_blank','imagewidth' => "100",'imageheight' => "100",);
$objCpm->cpm_viewLastAddedMedia(1,4,$options);
$objCpm->cpm_close();
?>

Just add the code to where you want to display them and you can add additional styling with CSS.