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.

We're retiring the forums!

The SilverStripe forums have passed their heyday. They'll stick around, but will be read only. We'd encourage you to get involved in the community via the following channels instead:

General Questions /

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

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

Images not showing up in Uploadfields Filebrowser

Go to End

4 Posts   1731 Views


Community Member, 8 Posts

18 October 2012 at 7:00am

Edited: 18/10/2012 7:20am


in multiple projects we extend the Image Class to add some Fields like "Caption" etc.

class CustomImage extends Image{
  //add fields, override getCMSFields() etc.

Now on a PageType which has many of those CustomImages those are managed with an uploadField

$has_many = array('CustomImages' => 'CustomImage')

$fields->addFieldToTab("Root.Main", new UploadField('CustomImages', 'Custom Images'), 'Content');

This works fine and Images upload via the uploadfield get the ClassName "CustomImage" in the "File" tab.

When browsing for files to add, instead of uploading them directly, only Files with ClassName "CustomImage" show up.
Files uploaded in the Files-section however got the default ClassName "Image" and are not showing up within folders.

Is there any way to use my custom Image type while still being able to add Images in the uploadfield via the Browser which
were added previously in the Files-section?

Merci d'advance :)




Administrator, 690 Posts

19 October 2012 at 12:26pm

It's better to use $many_many for linking to multiple images, otherwise it's impossible for an image to be linked in more than one place, which runs counter to the way the asset library is used elsewhere.

If you do use $has_many, make sure that you have added the relevant $has_one to Image.


Community Member, 8 Posts

22 October 2012 at 6:54am


Nevertheless i solved my actual problem by not extending image directly
(which might not be such a good idea at all, as it messes up the classnames in the "File" table)
but using the DataExtension Class:

class ImageExtension extends DataExtension

  static $db = array(
    'Alt' => 'Varchar'

  public function updateCMSFields(FieldList $fields) {
    $fields->addFieldToTab('Root.Main', new TextField('Alt', 'Alt'), 'Name');


Object::add_extension('Image', 'ImageExtension');

This way i could have an extra Alt-Text Field directly on the Image, which allows me to manage it using the uploadfield without the need for an additional dataobject and a gridfied...


Community Member, 21 Posts

16 November 2012 at 6:03pm

I'm having the same issue, slightly different, because I want to use $gd image manipulation functions within my extension.
Right now I have:

class CustomImage extends Image {
function generateProfileImage($gd) {
return $gd->resizeByWidth(110);

I don't think I will be able to use $gd functions if I change this to extend DataExtension...

Does anyone know a way to get UploadField to query files with class name CustomImage AND Image?