diff --git a/src/Plugin/entity_embed/EntityEmbedDisplay/MediaImageDecorator.php b/src/Plugin/entity_embed/EntityEmbedDisplay/MediaImageDecorator.php index 7d319eb..56302b8 100644 --- a/src/Plugin/entity_embed/EntityEmbedDisplay/MediaImageDecorator.php +++ b/src/Plugin/entity_embed/EntityEmbedDisplay/MediaImageDecorator.php @@ -177,6 +177,14 @@ class MediaImageDecorator implements EntityEmbedDisplayInterface { $values['alt'] = ''; } + // If the alt text is a empty string and entity image have value, + // Set the alt property. + if ($values['alt'] != $entity->{$image_field}->alt) { + if (empty(trim($values['alt']))) { + $values['alt'] = $entity->{$image_field}->alt; + } + } + $form_state->setValue(['attributes', 'alt'], $values['alt']); $form_state->unsetValue([ 'attributes',