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've moved the forum!

Please use forum.silverstripe.org for any new questions (announcement).
The forum archive will stick around, but will be read only.

You can also use our Slack channel or StackOverflow to ask for help.
Check out our community overview for more options to contribute.

Customising the CMS /

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

ModelAdmin image field allowed extensions


Go to End


2 Posts   1719 Views

Avatar
timwjohn

Community Member, 98 Posts

4 April 2010 at 10:46am

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?

Avatar
timwjohn

Community Member, 98 Posts

7 April 2010 at 3:13am

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