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.

General Questions

General questions about getting started with SilverStripe that don't fit in any of the categories above.

Moderators: martimiz, Sean, biapar, Willr, Ingo, swaiba, simon_w

Problem adding mutiple images to page

Go to End

13 Posts   2202 Views


23 July 2012 at 8:28am (Last edited: 23 July 2012 8:30am), Community Member, 145 Posts

Hi All,

I have a custom page with multiple images, and everything is working fine. It's built like this right now:

static $has_one = array(
'Photo' => 'Image',
'PhotoTwo' => 'Image',
'PhotoThree' => 'Image',
'PhotoFour' => 'Image',
'PhotoFive' => 'Image',
'SmallBanner' => 'Image'

The problem comes when I try to add just one more image, it blows up the site and I get "Sorry, there was a problem handling your request". I am using SS 2.4.5. Is there some sort of limit? Or a better way to do it? Or am I just missing something (besides brain cells)?



24 July 2012 at 9:46am Community Member, 20 Posts

Has a better way, use Data Object Manager


25 July 2012 at 12:41am Community Member, 44 Posts

Data Object Manager is not yet compatible with SilverStripe 3?

[User Deprecated] DataObjectDecorator->__construct is deprecated. Use DataExtension instead. Called from ReflectionClass->newInstance.


25 July 2012 at 1:01am (Last edited: 25 July 2012 1:08am), Community Member, 44 Posts

I just got this working, you do not need to install any module anymore in SilverStripe 3.0:

Because the [url=]UploadField can now handle multiple files/images[/url], we simply specify a has_many relationship and create a screenshot class that extends the [url=]Image DataObject[/url]. Remember to set a link back from the dataobject to the page type:


class YourPage extends Page {

   public static $has_many = array(
      'Screenshots' => 'Screenshot'

   public function getCMSFields() {
      $fields = parent::getCMSFields();
$fields->addFieldToTab('Root.Main', new UploadField('Screenshots'), 'Content');
      return $fields;

class Screenshot extends Image {
      public static $has_one = array(
         'YourPage' => 'YourPage'

Then, in your theme's
templates/Layout/, we can just call the has_many relationship and use all the Image class's methods:

<div class="content-container typography">   
      <div class="content">
            <% loop Screenshots %>
            <% end_loop %>
<% include SideBar %>


25 July 2012 at 5:47am Community Member, 145 Posts


Thanks for all the replies. That looks like a good solution. Haven't upgraded to 3.0 yet, I guess I better do that

For now I just can't see why the current code is there a quick and easy fix?



15 November 2012 at 1:47pm Community Member, 57 Posts

Thanks for this. Still trying to get my head around what SS3 can and can't do and this example was just what I needed.


31 January 2013 at 5:37pm Community Member, 6 Posts

Hi, this works on the CMS side, in the front-end form I can't seem to make this work using FileField.


8 February 2013 at 12:02am Community Member, 22 Posts

can someone tell me how to add a variable to get the images instead of $SetWidth ?

Go to Top