CoppermineSC is a WordPress plugin that can include images from Coppermine Photo Gallery in WordPress posts or templates. I wrote CoppermineSC based on a script by Lennart Groetzbach that was adapted as a plugin and enhanced by Matthias Jell.

The latest version of CoppermineSC is 0.4.6 What’s new in 0.4.6?

Key Features:

  • Support for links to an unlimited number of Coppermine databases.
  • You can include single images, albums, or categories.
  • When including single images, you can reference them by album id and image name or by permanent id from the Coppermine database, and you can choose thumbnails, normalized images, or full size images (with an optional maximum width setting).
  • When including albums or categories, you can include the entire set of images or a customizable fixed number of images in filename, date or title order, or you can choose to include a random set of images from a given album or category. You can also choose to include only the most recently uploaded images.
  • You can choose to include random images from your entire gallery, or the most recently images uploaded from your gallery.
  • A special function you can call to include images in your sidebar or elsewhere in your template.

Download And Information:

Installation Instructions:
In order to install CoppermineSC you will have to unzip the download, locate the ‘copperminesc.txt’ file, and do the following:

(Please note that you can simply ignore the ‘alternate_coppermine_database.txt’ file if you only have one Coppermine database, which is probably the case for most people. If you do have multiple Coppermine databases, you can find instructions on using the alternate database file near the bottom of this page.)

  1. Enter your Coppermine Gallery MySQL connection information in this area of the script:
    define ('CPGSC_DBUSER', 'mysql_user_here');
    define ('CPGSC_DBPASS', 'mysql_password_here');
    define ('CPGSC_DBSERVER', 'mysql_db_server_here');
    define ('CPGSC_DBNAME', 'mysql_db_name_here');
    define ('CPGSC_TABLE_PREFIX', 'cpg_');
    // for previous line, enter prefix for tables in db, might be based on Coppermine version number like 'cpg132_'

     
  2. CoppermineSC will run just fine without altering any of the following settings, but if want to tailor its output to your needs, you can optionally customize (alter or comment in or out) the appropriate lines in the optional settings section:
    // set prefix for normalized and thumbnail images (these are the defaults, but you can change them if you have customized Coppermine)
    define ('CPGSC_NORMAL_PREFIX', 'normal_');
    define ('CPGSC_THUMB_PREFIX', 'thumb_');

    // set sort order for images when including non-random images from an album, comment out all but one of the following four lines
    //define ('CPGSC_IMAGE_SORT', 'database');
    //define ('CPGSC_IMAGE_SORT', 'date');
    define ('CPGSC_IMAGE_SORT', 'filename');
    //define ('CPGSC_IMAGE_SORT', 'title');

    // set sort order for albums (within the selected category) when including non-random images from a category, comment out all but one of the following three lines
    //define ('CPGSC_ALBUM_SORT', 'database');
    define ('CPGSC_ALBUM_SORT', 'albumorder');
    //define ('CPGSC_ALBUM_SORT', 'title');

    // set whether individual image links should link to the normal size image or to the album they belong to (does not effect album, category, or gallery based thumbnails), comment out exactly one of the following two lines
    define ('CPGSC_SINGLEIMAGE_LINK', 'album');
    //define ('CPGSC_SINGLEIMAGE_LINK', 'normalimage');

    // optional text for album link (blank text means no link will be created), comment out exactly one of the following two lines
    //define ('CPGSC_ALBUM_TEXT', '');
    define ('CPGSC_ALBUM_TEXT', 'view more images from this album');

    // optional text for category link (blank text means no link will be created), comment out exactly one of the following two lines
    //define ('CPGSC_CATEGORY_TEXT', '');
    define ('CPGSC_CATEGORY_TEXT', 'view more images from this category');

    // optional text for gallery link (blank text means no link will be created), comment out exactly one of the following two lines
    //define ('CPGSC_GALLERY_TEXT', '');
    define ('CPGSC_GALLERY_TEXT', 'view more images from this gallery');

    // optional forced width for full size original image (blank forced width means actual width will be used, you can customize the fixed width if you want to), comment out exactly one of the following two lines
    define ('CPGSC_MAX_WIDTH', '');
    //define ('CPGSC_MAX_WIDTH', ' style="width:400px;"');

    // optional forced horizontal alignment for images (blank means follow css tags as listed in Layout section above), comment out all but one of the following four lines
    define ('CPGSC_ALIGNMENT', '');
    //define ('CPGSC_ALIGNMENT', 'left');
    //define ('CPGSC_ALIGNMENT', 'center');
    //define ('CPGSC_ALIGNMENT', 'right');

    // set whether or not clicking on an image should open a new window, comment out exactly one of the following two lines
    define ('CPGSC_NEWWINDOW', 'no');
    //define ('CPGSC_NEWWINDOW', 'yes');

    // set whether or not CoppermineSC tags work in comments, comment out exactly one of the following two lines
    //define ('CPGSC_ALLOW_COMMENTS', 'allowed');
    define ('CPGSC_ALLOW_COMMENTS', 'notallowed');

    // set whether the image containing element is a span or a div tag, comment out exactly one of the following two lines
    //define ('CPGSC_CONTAINER_ELEMENT', 'div');
    define ('CPGSC_CONTAINER_ELEMENT', 'span');

    // set whether or not you want to use a containing element for tags that include individual images, comment out exactly one of the following two lines
    //define ('CPGSC_CONTAINER_INDIVIDUAL', 'no');
    define ('CPGSC_CONTAINER_INDIVIDUAL', 'yes');
     

  3. Rename the file with a “php” extension (it will be “txt” when you download it)
     
  4. Upload it to your plugins directory and activate it
     
  5. You’re done!

Usage:
To use the plugin in WordPress, add one of the following lines in an entry:

  • The following tags pull in images from the main database
    • These tags pull in a single image from the main database by album id and image name
      [cpg_image:2,myimage.jpg] – inserts full size/original image for image in album id 2 named ‘myimage.jpg’
      [cpg_imagenormal:2,myimage.jpg] – inserts normalized image for image in album id 2 named ‘myimage.jpg’
      [cpg_imagethumb:2,myimage.jpg] – inserts thumbnail image for image in album id 2 named ‘myimage.jpg’
    • These tags pull in a single image from the main database by permanent image id
      [cpg_imagefix:1234] – inserts full size/original image with permanent id 1234
      [cpg_imagefixnormal:1234] – inserts normalized image with permanent id 1234
      [cpg_imagefixthumb:1234] – inserts thumbnail image with permanent id 1234
       
    • These tags pull in thumbnails of images from a specific album in the main database
      [cpg_album:4] – inserts thumbnails for all images in album id 4
      [cpg_album:4,10] – inserts thumbnails for the first 10 images in album 4
      [cpg_albumnew:4] – inserts thumbnails for all images in album id 4 in order from newest to oldest
      [cpg_albumnew:4,10] – inserts thumbnails for the 10 latest uploads from the images in album id 4
      [cpg_albumrand:4] – inserts thumbnails for all images in album id 4 in random order
      [cpg_albumrand:4,10] – inserts 10 random thumbnails from the images in album id 4
    • These tags pull in full size / original images from a specific album in the main database
      [cpg_albumfullsize:4] – inserts full size / original images for all images in album id 4
      [cpg_albumfullsize:4,10] – inserts full size / original images for the first 10 images in album 4
      [cpg_albumnewfullsize:4] – inserts full size / original images for all images in album id 4 in order from newest to oldest
      [cpg_albumnewfullsize:4,10] – inserts full size / original images for the 10 latest uploads from the images in album id 4
      [cpg_albumrandfullsize:4] – inserts full size / original images for all images in album id 4 in random order
      [cpg_albumrandfullsize:4,10] – inserts 10 random full size / original images from the images in album id 4
       
    • These tags pull in thumbnails of images from a specific category in the main database
      [cpg_cat:5] – inserts thumbnails for all images in category id 5
      [cpg_cat:5,12] – inserts thumbnails for the first 12 images in category id 5
      [cpg_catnew:5] – inserts thumbnails for all images in category id 5 in order from newest to oldest
      [cpg_catnew:5,12] – inserts thumbnails for the 12 latest uploads from the images in category id 5
      [cpg_catrand:5] – inserts thumbnails for all images in category id 5 in random order
      [cpg_catrand:5,12] – inserts 12 random thumbnails from the images in category id 5
    • These tags pull in full size / original images from a specific category in the main database
      [cpg_catfullsize:5] – inserts full size / original images for all images in category id 5
      [cpg_catfullsize:5,12] – inserts full size / original images for the first 12 images in category id 5
      [cpg_catnewfullsize:5] – inserts full size / original images for all images in category id 5 in order from newest to oldest
      [cpg_catnewfullsize:5,12] – inserts full size / original images for the 12 latest uploads from the images in category id 5
      [cpg_catrandfullsize:5] – inserts full size / original images for all images in category id 5 in random order
      [cpg_catrandfullsize:5,12] – inserts 12 random full size / original images from the images in category id 5
       
    • These tags pull in thumbnails of images from your entire gallery in the main database
      [cpg_galnew:3] – insert thumbnails for the 3 latest uploads from all the images in the gallery
      [cpg_galrand:3] – inserts 3 random thumbnails from all the images in the gallery
    • These tags pull in full size / original images from your entire gallery in the main database
      [cpg_galnewfullsize:3] – insert full size / original images for the 3 latest uploads from all the images in the gallery
      [cpg_galrandfullsize:3] – inserts 3 random full size / original images from all the images in the gallery
       
  • The following tags pull in images from an additional database
    • These tags pull in a single image from an alternate database by album id and image name
      [cpg_dbimage:mydbname,2,myimage.jpg] – inserts full size/original image for image in album id 2 named ‘myimage.jpg’ from database named ‘mydbname’
      [cpg_dbimagenormal:mydbname,2,myimage.jpg] – inserts normalized image for image in album id 2 named ‘myimage.jpg’ from database named ‘mydbname’
      [cpg_dbimagethumb:mydbname,2,myimage.jpg] – inserts thumbnail image for image in album id 2 named ‘myimage.jpg’ from database named ‘mydbname’
    • These tags pull in a single image from an alternate database by permanent image id
      [cpg_dbimagefix:mydbname,1234] – inserts full size/original image with permanent id 1234 from database named ‘mydbname’
      [cpg_dbimagefixnormal:mydbname,1234] – inserts normalized image with permanent id 1234 from database named ‘mydbname’
      [cpg_dbimagefixthumb:mydbname,1234] – inserts thumbnail image with permanent id 1234 from database named ‘mydbname’
       
    • These tags pull in thumbnails of images from a specific album in an alternate database
      [cpg_dbalbum:mydbname,4] – inserts thumbnails for all images in album id 4 from database named ‘mydbname’
      [cpg_dbalbum:mydbname,4,10] – inserts thumbnails for the first 10 images in album 4 from database named ‘mydbname’
      [cpg_dbalbumnew:mydbname,4] – inserts thumbnails for all images in album id 4 in order from newest to oldest from database named ‘mydbname’
      [cpg_dbalbumnew:mydbname,4,10] – inserts thumbnails for the 10 latest uploads from the images in album id 4 from database named ‘mydbname’
      [cpg_dbalbumrand:mydbname,4] – inserts thumbnails for all images in album id 4 in random order from database named ‘mydbname’
      [cpg_dbalbumrand:mydbname,4,10] – inserts 10 random thumbnails from the images in album id 4 from database named ‘mydbname’
    • These tags pull in full size / original images from a specific album in an alternate database
      [cpg_dbalbumfullsize:mydbname,4] – inserts full size / original images for all images in album id 4 from database named ‘mydbname’
      [cpg_dbalbumfullsize:mydbname,4,10] – inserts full size / original images for the first 10 images in album 4 from database named ‘mydbname’
      [cpg_dbalbumnewfullsize:mydbname,4] – inserts full size / original images for all images in album id 4 in order from newest to oldest from database named ‘mydbname’
      [cpg_dbalbumnewfullsize:mydbname,4,10] – inserts full size / original images for the 10 latest uploads from the images in album id 4 from database named ‘mydbname’
      [cpg_dbalbumrandfullsize:mydbname,4] – inserts full size / original images for all images in album id 4 in random order from database named ‘mydbname’
      [cpg_dbalbumrandfullsize:mydbname,4,10] – inserts 10 random full size / original images from the images in album id 4 from database named ‘mydbname’
       
    • These tags pull in thumbnails of images from a specific category in an alternate database
      [cpg_dbcat:mydbname,5] – inserts thumbnails for all images in category id 5 from database named ‘mydbname’
      [cpg_dbcat:mydbname,5,12] – inserts thumbnails for the first 12 images in category 5 from database named ‘mydbname’
      [cpg_dbcatnew:mydbname,5] – inserts thumbnails for all images in category id 5 in order from newest to oldest from database named ‘mydbname’
      [cpg_dbcatnew:mydbname,5,12] – inserts thumbnails for the 12 latest uploads from the images in category id 5 from database named ‘mydbname’
      [cpg_dbcatrand:mydbname,5] – inserts thumbnails for all images in category id 5 in random order from database named ‘mydbname’
      [cpg_dbcatrand:mydbname,5,12] – inserts 12 random thumbnails from the images in category id 5 from database named ‘mydbname’
    • These tags pull in full size / original images from a specific category in an alternate database
      [cpg_dbcatfullsize:mydbname,5] – inserts full size / original images for all images in category id 5 from database named ‘mydbname’
      [cpg_dbcatfullsize:mydbname,5,12] – inserts full size / original images for the first 12 images in category 5 from database named ‘mydbname’
      [cpg_dbcatnewfullsize:mydbname,5] – inserts full size / original images for all images in category id 5 in order from newest to oldest from database named ‘mydbname’
      [cpg_dbcatnewfullsize:mydbname,5,12] – inserts full size / original images for the 12 latest uploads from the images in category id 5 from database named ‘mydbname’
      [cpg_dbcatrandfullsize:mydbname,5] – inserts full size / original images for all images in category id 5 in random order from database named ‘mydbname’
      [cpg_dbcatrandfullsize:mydbname,5,12] – inserts 12 random full size / original images from the images in category id 5 from database named ‘mydbname’
       
    • These tags pull in thumbnails of images from your entire gallery from database named ‘mydbname’
      [cpg_dbgalnew:mydbname,3] – insert thumbnails for the 3 latest uploads from all the images in the gallery from database named ‘mydbname’
      [cpg_dbgalrand:mydbname,3] – inserts 3 random thumbnails from all the images in the gallery from database named ‘mydbname’
    • These tags pull in full size / original images from your entire gallery from database named ‘mydbname’
      [cpg_dbgalnewfullsize:mydbname,3] – insert full size / original images for the 3 latest uploads from all the images in the gallery from database named ‘mydbname’
      [cpg_dbgalrandfullsize:mydbname,3] – inserts 3 random full size / original images from all the images in the gallery from database named ‘mydbname’
       
  • The following tags are for use outside normal entries (for example, in your sidebar or template)
    • Use a snippet like the following in your sidebar or template:
      <?php if (function_exists('cpgsc_sidebar')) {
          cpgsc_sidebar('any_tag_from_list_above'); }
      ?>
    • For example, to insert thumbnails for all images in album id 4:
      <?php if (function_exists('cpgsc_sidebar')) {
          cpgsc_sidebar('[cpg_album:4]'); }
      ?>

Instructions For Additional Databases:
If you want to link to more than one Coppermine Gallery, you will need to follow these instructions. In order to use any of the [cpg_db tags, you will have to create a configuration file for each of the Coppermine databases you want to access. The contents of a configuration file should be as follows:

<?php
$alternateserver = 'alternate_mysql_db_server_here';
$alternatedbname = 'alternate_mysql_db_name_here';
$alternatepassword = 'alternate_mysql_password_here';
$alternateuser = 'alternate_mysql_user_here';
$alternatetableprefix = 'cpg_';
/* do not alter any lines in this file other than replacing
the placeholders with your connection information,
do not remove any lines from this file,
do not add any lines or carriage returns */
?>

You can download a template configuration file here. You will need to save the file as “databasename.php”. For example, if your Coppermine database is named “my_coppermine1”, then save the file as “my_coppermine1.php”. The file must be saved in the “wp-content” folder in your WordPress setup. Please note that this is not the “plugins” folder or a subfolder where you may have installed the plugin. The configuration files need to be installed directly into the “wp-content” folder in order to work.

When you use one of the [cpg_db tags, use the database name as the first parameter, such as: [cpg_dbalbum:my_coppermine1,4] to insert thumbnails for all images in album id 4 from database “my_coppermine1”.

What’s Next?

  • An admin page in WordPress for configuring the main settings (so you won’t have to hand edit the script anymore).
  • Enhancements to the admin page to allow you to set up additional databases (so you won’t have to use separate alternate database files anymore).
  • It depends on what you ask for! Please post requests here.

Special Thanks:

  • Lennart Groetzbach for his original work and idea.
  • Matthias Jell for his enhancements and conversion of the original script to a plugin.
  • Richard Rosalion for first noticing that the original routine in Matthias Jell’s plugin might read right past the ending “]” character when looking for a comma.
  • Tim for information on how to directly link to an image in Coppermine using its permanent id.
  • Bitweever for encouraging me to learn how to make this plugin work in sidebars.
  • Rob for pointing out the problem with private galleries.
  • Kathy Moore for suggesting the set of tags to pull the most recently uploaded images for albums, categories, or for the entire gallery.
  • Brian Jarrett for suggesting a fix for a WordPress 2.5 compatibility problem.

21 Responses to “CoppermineSC Plugin”


  1. […] The Coppermine plugin is looking fairly interesting so far, because I was able to install Coppermine itself so easily onto my site, thanks to a nifty script centre provided by my web host, but at the moment the integration with WP is hit and miss. I can link to images that are in coppermine fairly easily – see the photos in the right column for an example of this – but there’s a sense of disconnection between the two while my Coppermine stylesheet is so different from the WP stylesheet. Using the excellent Run PHP plugin, I can also call up images from a gallery and display them easily in posts, and I’ve started hacking the php for the CoppermineSC plugin a bit so I can define more styles and classes so I have more control over how images look in posts. As an example, for the image at the top of this post, I’ve added lines to the plugin so I can define the picture not only as a thumbnail, but give it a class=”alignleft” attribute so it matches how I like all my post introduction images to look. […]


  2. […] Die bereits existierende Coppermine Anbindung an eine WordPress Seite ist ja sehr schön (dank an Brad für CoppermineSC). Ich wollte jedoch gerne quadratische Vorschaubilder innerhalb meiner Webseite integrieren. Dazu habe ich das Plug-In etwas erweitert, so dass es nun on-the-fly (wenn nicht schon in einem früheren Request generiert) Squarethumbnails erzeugt. Der Diff zur Version 0.4.2. […]


  3. […] Rue Plumet – CoppermineSC Plugin […]


  4. […] Por otro lado encontré el CoppermineSC, un fantástico plugin para el WordPress que permite integrar fotos de la galería en cualquier sitio del blog, tanto fotos sueltas y fijas, como la cantidad que elijas, aleatorias, o de alguna galería en concreto. Por el momento he puesto lo de foto al azar, y a partir de ahora las fotos de los artículos vendrán directamente de la galería. […]


  5. […] Added a new plugin to make it easier for me to post pics from my gallery. It’s called Coppermine SC. […]


  6. […] I have started using the CoppermineCS plugin by Brad Guilford. Random images from my image gallery. view more images from this gallery […]


  7. […] The amazing Coppermine SC Plugin, from Frenchman Brad of blog 55RuePlumet.com. He made his version from (American?)Matthias Jell, who in turn got the original from German Lennart Groetzbach, to enhance our Philippine Sorority blog with pictures hosted on the Portia Coppermine Photo Gallery. […]


  8. […] CoppermineSC: Dieses Plugin ist dafür zuständig meine Coppermine Gallery in meine Posts integrieren zu können. […]


  9. […] How did I do this?  CoppermineSC.  It’s tasty. Share and […]


  10. […] but where the website is (godaddy)).  I’ve got Coppermine up and running and am using the coppermineSC plugin for WordPress.  That’s the plan so far.  You can see one little picture under the […]


  11. […] the CoppermineSC plugin to see if the coppermine album (sitting on croes-album.de) will […]


  12. […] know WordPress 2.5 RC2 is out now. I’m now using it but I had a major issue with one plugin: CoppermineSC. This plugin allows me to tie my Coppermine photo gallery into my WordPress blog. When activated it […]


  13. […] consuming). In order to import Coppermine galleries into WordPress I use the plug-in CoppermineSC.http://www.rueplumet.com/plugins/copperminesc/The installation instructions are pretty clear except for inputting the server information, since […]


  14. […] CoppermineSC bietet die Möglichkeit Bilder der Open-Source Coppermine Gallery in den Blog einzubauen. Es können ganze Alben oder Zufallsbilder in den Blog übernommen werden. […]


  15. […] the combination of a wordpress plugin, (copperminesc), I’ve been able to integrate Coppermine with WordPress. For now, I’ve created a new […]


  16. […] images inside the WordPress GUI. As of today, the best sources on this include Rue Plumet’s CoppermineSC plugin and Cyberspice’s WordPress Coppermine Widget. I have passed over […]


  17. […] CoppermineSC Plugin November 20th, 2009 in Uncategorized […]


  18. […] Key Features: * Support for links to an unlimited number of Coppermine databases. * You can include single images, albums, or categories. * When including single images, you can reference them by album id and image name or by permanent id from the Coppermine database, and you can choose thumbnails, normalized images, or full size images (with an optional maximum width setting). * When including albums or categories, you can include the entire set of images or a customizable fixed number of images in filename, date or title order, or you can choose to include a random set of images from a given album or category. You can also choose to include only the most recently uploaded images. * You can choose to include random images from your entire gallery, or the most recently images uploaded from your gallery. * A special function you can call to include images in your sidebar or elsewhere in your template. Rueplumet – copperminesc […]


  19. […] otro lado encontré el CoppermineSC, un fantástico plugin para el WordPress que permite integrar fotos de la galería en cualquier […]


  20. Hey I know this is off topic but I was wondering
    if you knew of any widgets I could add to my blog that automatically
    tweet my newest twitter updates. I’ve been looking for a plug-in like this for quite some time and was hoping maybe you would have some experience with something like this. Please let me know if you run into anything. I truly enjoy reading your blog and I look forward to your new updates.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s