public function AmpVideoFormatter::viewElements in Accelerated Mobile Pages (AMP) 8.2
Same name and namespace in other branches
- 8.3 src/Plugin/Field/FieldFormatter/AmpVideoFormatter.php \Drupal\amp\Plugin\Field\FieldFormatter\AmpVideoFormatter::viewElements()
- 8 src/Plugin/Field/FieldFormatter/AmpVideoFormatter.php \Drupal\amp\Plugin\Field\FieldFormatter\AmpVideoFormatter::viewElements()
Builds a renderable array for a field value.
Parameters
\Drupal\Core\Field\FieldItemListInterface $items: The field values to be rendered.
string $langcode: The language that should be used to render the field.
Return value
array A renderable array for $items, as an array of child elements keyed by consecutive numeric indexes starting from 0.
Overrides GenericFileFormatter::viewElements
File
- src/
Plugin/ Field/ FieldFormatter/ AmpVideoFormatter.php, line 78
Class
- AmpVideoFormatter
- Plugin implementation of the 'amp_video' formatter.
Namespace
Drupal\amp\Plugin\Field\FieldFormatterCode
public function viewElements(FieldItemListInterface $items, $langcode) {
$elements = parent::viewElements($items, $langcode);
foreach ($elements as $delta => $element) {
$elements[$delta]['#theme'] = 'amp_video';
$elements[$delta]['#attributes']['height'] = $this
->getSetting('amp_video_height');
$elements[$delta]['#attributes']['width'] = $this
->getSetting('amp_video_width');
}
return $elements;
}