5121 Posts in 1527 Topics by 1119 members
|
Page:
1
|
Go to End | |
| Author | Topic: | 1292 Views |
-
Image Field Not Showing Attached Image

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 http://www.ssbits.com/tutorials/2011/improving-image-quality-by-preventing-correctly-sized-images-being-resized/
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
-
Re: Image Field Not Showing Attached Image

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);
| 1292 Views | ||
|
Page:
1
|
Go to Top |


