Skip to content

Commit

Permalink
Merge pull request #37 from NobrainerWeb/fix-template-thumbnail-html-…
Browse files Browse the repository at this point in the history
…broken

show template thumbnails correctly again
  • Loading branch information
sanderha authored Dec 19, 2016
2 parents c19ba52 + 1adb198 commit 9d1854e
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion code/dataobjects/Block.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,16 @@ class Block extends DataObject
"RedirectionType" => "Internal"
);

private static $casting = array(
'createStringAsHTML' => 'HTMLText'
);

public function createStringAsHTML($html){
$casted = HTMLText::create();
$casted->setValue($html);
return $casted;
}

public function populateDefaults()
{
$this->Template = $this->class;
Expand Down Expand Up @@ -177,7 +187,7 @@ public function getCMSFields()
// Is there a template thumbnail
$thumbnail = (file_exists($src . $name . '.png') ? '<img src="' . $imgsrc . $name . '.png" />' : '<img src="' . $imgsrc . 'Blank.png" />'); // TODO: Perhaps just add blank as alt for image, no need to check for existance?
$html = '<div class="blockThumbnail">' . $thumbnail . '</div><strong class="title" title="Template file: ' . $filename . '">' . $name . '</strong>';
$optionset[$name] = $html;
$optionset[$name] = $this->createStringAsHTML($html);
}

$tplField = OptionsetField::create(
Expand Down

0 comments on commit 9d1854e

Please sign in to comment.