I'm trying to write a function that displays images from the child pages on the Holder Page.
Because SilverStripe lacks some functionality on templates I figured it will be best to process it all in the controller.
There are some conditional statements I require which can only be done in php.
Controller.php
public function LatestWork() {
$works = WorkPage::get();
$i = 1;
$html = "";
foreach ($works as $work) {
//Build the IMage Object so we can add it to the Work Object
$ImageObj = File::get()->byID($work->FeaturedImageID);
if ($this->is_odd($i)) {
$html .= "<div class='row'>";
$span = "span8";
} else {
$span = "span4";
}
$html .= "<div class = '$span'>" . $ImageObj->croppedImage(200,100) . "</div>";
if ($this->is_even($i) || $i == $works->Count()) {
$html .= "</div>";
}
$i++;
}
return $html;
}
When its processed in the view the divs and spans are there but the image is not. There are more conditions in the code but this is just the basic version. It displays "Image_Cached" instead.
How can I make it display the image?