If your doing a few sites that need collections of images of some description its definitely worth getting to know uncle cheese's DataObjectManager. I've used the filedataobjectmanager class to feed images into slide show pro or shadow box thumbs. Taking the time to do it yourself means its much easier to customise image resizing for thumbnails and/or larger full size images.
The following is the most complicated part about implementing it (I did this a few days ago for use with the shopping module, you might want to call it GalleryImageObject....)
<?php
class ProductImageObject extends DataObject
{
static $default_sort = "SortOrder";
static $db = array (
);
static $has_one = array (
'ProductImage' => 'Image'
);
public function getCMSFields_forPopup()
{
return new FieldSet(
new FileIFrameField('ProductImage')
);
}
public function Thumbnail()
{
return $this->ProductImage()->CroppedImage(120,120);
}
public function Large()
{
return $this->ProductImage()->CroppedImage(300,300);
}
}
?>
With a class like above, if you need captions of links wrapped around your images you can just add fields to $db and add the appropriate form field to the popup function.
Then on your gallery page add a has many relationship to the above dataobject, and uncle cheese's FileDataObjectManager, which I found difficult getting my head round the first time I used it.
class Product extends Page {
static $has_many = array (
'ProductImages' => 'ProductImageObject',
);
function getCMSFields() {
$fields = parent::getCMSFields();
// Allow Multiple Images
$manager = new FileDataObjectManager(
$this, // Controller
'ProductImages', // Source name
'ProductImageObject', // Source class
'ProductImage', // File name on DataObject
// this array was left in from the last time I used this manager (i think)
array(
//'Name' => 'Name',
//'Caption' => 'Caption',
//'Category' => 'Category'
), // Headings
'getCMSFields_forPopup' // Detail fields (function name or FieldSet object)
// Filter clause
// Sort clause
// Join clause
);
$manager->sort = 'SortOrder';
$manager->sort_dir = "ASC";
$manager->setAllowedFileTypes(array('jpg','gif','png'));
$manager->setBrowseButtonText("Upload");
$manager->setGridLabelField('Name');
$manager->setPluralTitle('Product Images');
$fields->addFieldToTab("Root.Content.ProductImages", $manager);
return $fields;
}
}
Then on my Product.ss page or for you ArtistGalleryPage.ss I have.
<div id="ThumbNails">
<% control ProductImages %>
<img src="{$Thumbnail.Filename}" alt="{$Large.Filename}" />
<% end_control %>
</div>
You could just have
<% control ProductImages %>
$Thumbnail
<% end_control %>
But I was using the alt attribute for a javascript function.
I hope that helps. The FileDataObjectManager is awesome, mainly because it gives you a little thumbnail of the image in the admin.
And if you add
SortableDataObject::add_sortable_class('ProductImageObject');
to yoursite/dataobjectmanager/_config.php
you can drag and drop your images around to reorder them in the future, very useful!