Tutorial: Add image sizes under thumbs in Coppermine

Tutorial: Add image sizes under thumbs in Coppermine

If you use the Coppermine script to run a photo gallery, you might want to show your visitors the size of the full picture before they click on it.

In this tutorial I will show you how to modify the functions file in order to display the image size under the thumbnails.

Modifying the Coppermine template

1. Go to your gallery folder -> Open the include folder -> Open to edit the file functions.inc.php

2. Search for this line

if (in_array('pic_rating', $must_have)) {

and right above it add this piece of code

$caption .= '<span class="thumb_dimensions">' . $rowset[$key]['pwidth'] . " x " . $rowset[$key]['pheight'] . '</span>';
$rowset[$key]['caption_text'] = $caption;

That’s it! Check out the live demo of Premade #19 to see it in action.

Something more

The above will add the image sizes under the upload date of the photo. You can also make the sizes to appear before the upload date by adding the code before the line

if (in_array('ctime', $must_have)) {

My themes use the span class thumb_dimensions to style the image sizes. You can change it in the code to suit your theme.

Wrap up

Upgrading the Coppermine script involves overwriting the existing files, including functions.inc.php. The image sizes will stop appearing.

You’ll need to repeat the steps in this tutorial on every upgrade you perform to keep the image sizes visible.

Let me know below if you have any questions or concerns.

Leave a Reply

Your email address will not be published. Required fields are marked *