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.

Customising the CMS /

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

Image Field Not Showing Attached Image

Go to End

2 Posts   1957 Views


Community Member, 545 Posts

15 January 2011 at 5:48am

I'm having a problem. I have multiple Images Attached to a DataObject and an onBeforeWrite that builds relation to the image file based on Data on DataObject. This all works fine. however the when I open the DataObject in ModelAdmin the attached images don't show up in the ImageField. The images IDs associate properly as I'm using a custom getter for the Summary FIelds and I can see the images with it.

Has One Relation:

	static $has_one = array (
		"FrontWeb_Image" => "BetterImage",
		"BackWeb_Image" => "BetterImage",
		"FrontHi_Image" => "BetterImage",
		"BackHi_Image" => "BetterImage",

Custom Getter for Summary Field:

	public function getSummaryImage() {
		if ($this->FrontWeb_ImageID) {
			$image = DataObject::get_by_id("File", $this->FrontWeb_ImageID);
			return $image->setWidth(100);
		} else {
			return "No Image Available";	

BetterImage is just an image quality function based on

The Thumbnails do show if I manually add the image from the ImageField.

If this is impossible another option I'm willing to use is listing the images in a CompositeField but custom getters won't work inside the getCMSFields function.

Thanks for any help


Community Member, 4 Posts

28 March 2012 at 4:59am

$image = DataObject::get_by_id("File", $this->FrontWeb_ImageID); 
return $image->setWidth(100); 

instead $image->setWidth(100); use getFormattedImage() like so:

return $image->getFormattedImage('SetWidth', 100);