public function MediaImage::getAttributeValues in Lightning Media 8
Same name and namespace in other branches
- 8.4 src/Plugin/entity_embed/EntityEmbedDisplay/MediaImage.php \Drupal\lightning_media\Plugin\entity_embed\EntityEmbedDisplay\MediaImage::getAttributeValues()
- 8.2 src/Plugin/entity_embed/EntityEmbedDisplay/MediaImage.php \Drupal\lightning_media\Plugin\entity_embed\EntityEmbedDisplay\MediaImage::getAttributeValues()
- 8.3 src/Plugin/entity_embed/EntityEmbedDisplay/MediaImage.php \Drupal\lightning_media\Plugin\entity_embed\EntityEmbedDisplay\MediaImage::getAttributeValues()
Gets the values for all attributes.
Return value
array An array of set attribute values, keyed by attribute name.
Overrides EntityEmbedDisplayBase::getAttributeValues
File
- src/
Plugin/ entity_embed/ EntityEmbedDisplay/ MediaImage.php, line 50
Class
- MediaImage
- Renders a media item's image via the image formatter.
Namespace
Drupal\lightning_media\Plugin\entity_embed\EntityEmbedDisplayCode
public function getAttributeValues() {
$field = $this
->getItem();
$label = $field
->getEntity()
->label();
// Try to default to the alt and title attributes set on the field item, but
// fall back to the entity label for both.
return parent::getAttributeValues() + [
'alt' => $field->alt ?: $label,
'title' => $field->title ?: $label,
];
}