Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

Customising the CMS

adding other details when you upload images

Go to End

14 Posts   1918 Views


24 March 2010 at 4:56am Community Member, 211 Posts


I hope this the right place to post this if not sorry

I have to add images cms and use them later on in the website

Waht I want to achieve is being able to add fields like Title, author or dimensions to these image then use them later on in the cms.

Is this the way to do things or do I have to create a template.

I don't know wich way to go and I'd like someone to help me chooese the rigt direction to achieve this.

Thanks a lot for advice

Carbon Crayon

24 March 2010 at 5:57am Community Member, 598 Posts

Hi Servalman

Have a look at the ImageDataObjectManager, which comes as part of the Data Object manager module.

You basically create a dataobject for your image with a has_one image relationship and can add as many fields as you like. Then when you upload them through the ImageDataObjectManager, it will go through and ask for the details of each image you just uploaded.

Here are the docs for the DOM (they are a little out of date):

Aram - SilversStripe tutorials, tips and other bits


24 March 2010 at 5:59am Community Member, 323 Posts


I did it by creating an extension to DataObject, I didn’t manage to make it work as I wanted by extending Image class directly, don’t remember why…

Hope it helps,


** You haven't been able to extend directly Image and add the boolean field
class MyImage extends DataObject {
   static $db = array (
      'ShowImagesTitle' => 'Boolean',
      'Legend' => 'Text'
   static $has_one = array (
      'Image' => 'Image',
      'Page' => 'Page'
   public function getCMSFields_forPopup()   {
      $myImageField = new ImageField('Image');
      return new FieldSet(
         new TextField('Legend'),
         new CheckboxField('ShowImagesTitle', 'Show legend')



   // Pages can have many images (see MyImage for the other side of the relation)
   public static $has_many = array(
      'Images' => 'MyImage'

And an example of using this in a Menu2 template:

   <% if Images %>
   <div class="menu2 images">
      <% control Images %>
         <% if ShowImagesTitle %><p>$Legend</p><% end_if %>
      <% end_control %>
   <% end_if %>


24 March 2010 at 6:03am Community Member, 211 Posts

Thank you both for your answers.

I will look at them closely.

But if I undesrtand the process I will be able to upload images with their details then use them later or have them used by someone else in a page.

Am I correct ?


Carbon Crayon

24 March 2010 at 6:15am Community Member, 598 Posts

What is the workflow that you want to achieve? When you say used by other people on other pages what do you mean? Are you talking about the TinyMCE content editor or some custom image manager?

Also what do you mean by 'use them later'? If you could explain the actual use case that would be helpful.

Aram - SilverStripe tutorials, tip and other bits


24 March 2010 at 6:24am Community Member, 211 Posts

Thank's for your concern :

I' going to try to be clear.

The project is for an artist who want's to show his work.

step 1 :
Uploading several images with all their details title, dimensions, materials, price etc.

step 2 :
showing those pictures in different sections of the website (galleries, text page etc..) sometimes with all the details sometimes with just some of them.

step 2.5 (that's an option for later on) :
allowing the website editors to choose wich details they want to show

Hope i'm clearer ;)



24 March 2010 at 9:14am Community Member, 323 Posts

Yes, I think you could use the code sent before for doing that. Just add more checkboxes…


24 March 2010 at 10:23am Community Member, 211 Posts

Thanks for your advice
I Will try and let you Know if it works

Go to Top