Jump to:

23360 Posts in 18097 Topics by 2862 members

General Questions

SilverStripe Forums » General Questions » Overridden Image class DataObject member cannot see any images uploaded via CMS File Manager

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

Page: 1
Go to End
Author Topic: 255 Views
  • vwd
    Avatar
    Community Member
    158 Posts

    Overridden Image class DataObject member cannot see any images uploaded via CMS File Manager Link to this post

    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.

    255 Views
Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.