public function ImageBrowserPreview::render in Image Entity Browser 8
Renders the field.
Parameters
\Drupal\views\ResultRow $values: The values retrieved from a single row of a view's query result.
Return value
string|\Drupal\Component\Render\MarkupInterface The rendered output. If the output is safe it will be wrapped in an object that implements MarkupInterface. If it is empty or unsafe it will be a string.
Overrides FieldPluginBase::render
File
- src/
Plugin/ views/ field/ ImageBrowserPreview.php, line 23 - Contains \Drupal\image_browser\Plugin\views\field.
Class
- ImageBrowserPreview
- Defines a custom field that renders a preview of a file, for the purposes of.
Namespace
Drupal\image_browser\Plugin\views\fieldCode
public function render(ResultRow $values) {
/** @var \Drupal\file\Entity\File $file */
$file = $values->_entity;
if ($file
->getMimeType() == 'image/svg+xml') {
return $build = [
'#markup' => '<img src="' . file_create_url($file
->getFileUri()) . '"/>',
];
}
return $build = [
'#theme' => 'image_style',
'#style_name' => 'image_browser_thumbnail',
'#uri' => $file
->getFileUri(),
];
}