Skip to content

Commit

Permalink
FIX 7590: Image thumbnails broken in gridfield
Browse files Browse the repository at this point in the history
Delay converting the object to a string and escaping its value until the end of getColumnContent. Call formatValue BEFORE castValue, so that formatValue can create raw HTML by casting to HTMLText afterwards.
  • Loading branch information
jakr authored and Hamish Friedlander committed Jul 27, 2012
1 parent 5591017 commit 15e2efb
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions forms/gridfield/GridFieldDataColumns.php
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ public function getFieldCasting() {
* Caution: Make sure to escape special php-characters like in a normal php-statement.
* Example: "myFieldName" => '<a href=\"custom-admin/$ID\">$ID</a>'.
* Alternatively, pass a anonymous function, which takes two parameters:
* The value returned by Convert::raw2xml and the original list item.
* The value and the original list item.
*
* @param array $formatting
*/
Expand Down Expand Up @@ -126,18 +126,20 @@ public function getColumnContent($gridField, $record, $columnName) {
// Allow callbacks
if(is_array($columnInfo) && isset($columnInfo['callback'])) {
$method = $columnInfo['callback'];
$value = Convert::raw2xml($method($record));
$value = $method($record);

// This supports simple FieldName syntax
} else {
$value = Convert::raw2xml($gridField->getDataFieldValue($record, $columnName));
$value = $gridField->getDataFieldValue($record, $columnName);
}

$value = $this->castValue($gridField, $columnName, $value);
$value = $this->formatValue($gridField, $record, $columnName, $value);
$value = $this->castValue($gridField, $columnName, $value);
$value = $this->escapeValue($gridField, $value);

return $value;
return (is_object($value) && $value instanceof Object && $value->hasMethod('forTemplate'))
? $value->forTemplate()
: Convert::raw2xml($value);
}

/**
Expand Down

0 comments on commit 15e2efb

Please sign in to comment.