public function BlazyEntityTrait::getFieldRenderable in Blazy 8
Returns the formatted renderable array of the field.
2 calls to BlazyEntityTrait::getFieldRenderable()
- BlazyEntityReferenceBase::buildElement in src/
Dejavu/ BlazyEntityReferenceBase.php - Returns item contents.
- BlazyEntityReferenceBase::getCaption in src/
Dejavu/ BlazyEntityReferenceBase.php - Builds slide captions with possible multi-value fields.
File
- src/
Dejavu/ BlazyEntityTrait.php, line 43
Class
- BlazyEntityTrait
- A Trait common for supported entities.
Namespace
Drupal\blazy\DejavuCode
public function getFieldRenderable($entity, $field_name = '', $view_mode = 'full') {
$view = [];
$has_field = !empty($field_name) && isset($entity->{$field_name});
if ($has_field && !empty($entity->{$field_name}
->view($view_mode)[0])) {
$view = $entity
->get($field_name)
->view($view_mode);
// Prevents quickedit to operate here as otherwise JS error.
// @see 2314185, 2284917, 2160321.
// @see quickedit_preprocess_field().
// @todo: Remove when it respects plugin annotation.
$view['#view_mode'] = '_custom';
}
return $view;
}