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.

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

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


Go to End


771 Views

Avatar
vwd

Community Member, 166 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.