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

Overridden Image class DataObject member cannot see any images uploaded via CMS File Manager


Reply


351 Views

Avatar
vwd

Community Member, 160 Posts

18 March 2013 at 5:42am

Edited: 18/03/2013 5:43am

Hi,

I have extended the Image class to add some utility functions to generate thumbnails. However it seems that when attaching images to the DataObject this image belongs to, I cannot see any images added via the CMS File manager. Only the images added via the UploadField of this custom Image type are visible. Is this normal?

Custom Image:

<?php
class CustomImage extends Image {

   function generatePhotoThumb($gd){
      return $gd->croppedResize(196,187);
   }
}

DataObject it belongs to:

class MyDataObject extends DataObject
{
   static $has_one = array (
      'MyCustomImage' => 'CustomImage',
      'NormalImage' => 'Image'
   );

   public function getCMSFields()
   {
      return new FieldList(
         new UploadField('MyCustomImage', 'Custom Image'),
         new UploadField('NormalImage', 'Normal')         
      );
   }
}

The UploadField for NormalImage displays all the files in the Assets folder. However, the UploadField for MyCustomImage only displays images that were uploaded via the UploadField.

Is this normal behaviour?

Thanks.
VWD.