Jump to:

5540 Posts in 1738 Topics by 1224 members

Customising the CMS

SilverStripe Forums » Customising the CMS » ModelAdmin image field allowed extensions

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

Page: 1
Go to End
Author Topic: 1230 Views
  • timwjohn
    Avatar
    Community Member
    98 Posts

    ModelAdmin image field allowed extensions Link to this post

    Happy Easter! Hope every one of you gets a chocolate egg.

    Quick question about the scaffolded has_one Image field in ModelAdmin... Shouldn't it automatically be setting its allowedExtensions property to those of image files? Cos mine doesn't - it's stuck on All files. I've tried this:

          $image = new ImageField('Image');
          $image->allowedExtensions = array('jpg', 'jpeg');
          $fields->replaceField('Image', $image);

    Which doesn't work, and I've also tried replacing the field with a SWFUploadFileIFrameField with this code:

          SWFUploadConfig::addFileTypes(array('jpg', 'jpeg'));
          $fields->replaceField('Image', new SWFUploadFileIFrameField('Image','Upload an image'));

    Which throws:

    Fatal error: Class 'Image_Uploader' not found in C:\xampp\htdocs\wag\swfupload\code\SWFUploadFileIFrameField.php on line 47

    What am I missing?

  • timwjohn
    Avatar
    Community Member
    98 Posts

    Re: ModelAdmin image field allowed extensions Link to this post

    Anybody? I'm a little stuck and I know my client will break this unless I can fix it!

    1230 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.