Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

FIX 7590: Image thumbnails broken in gridfield

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...
commit 15e2efb55d982053bb3cf6a1a7472bcf58119e1d 1 parent 5591017
jakr jakr authored hafriedlander committed
Showing with 7 additions and 5 deletions.
  1. +7 −5 forms/gridfield/GridFieldDataColumns.php
12 forms/gridfield/GridFieldDataColumns.php
View
@@ -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
*/
@@ -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);
}
/**
Please sign in to comment.
Something went wrong with that request. Please try again.