Loading src/Form/ImageFieldToMediaForm.php +8 −4 Original line number Diff line number Diff line Loading @@ -332,12 +332,16 @@ class ImageFieldToMediaForm extends FormBase { foreach (array_keys($view_modes) as $view_mode) { $storage = $this->entityTypeManager->getStorage('entity_view_display'); $view_display = $storage->load($entity_type . '.' . $bundle . '.' . $view_mode); $image_component = $view_display->getComponent($image_field_name); // A view display like a "Teaser" may not have the image field. In this // case the "$image_component" will be NULL. So, we should check it out. if ($image_component) { $media_component = $view_display->getComponent($media_field_name); $media_component['weight'] = $image_component['weight']; $view_display->setComponent($media_field_name, $media_component)->save(); } } // ---------- Set for Form displays ------------------------. $form_modes = $this->entityDisplayRepository->getFormModeOptionsByBundle($entity_type, $bundle); Loading Loading
src/Form/ImageFieldToMediaForm.php +8 −4 Original line number Diff line number Diff line Loading @@ -332,12 +332,16 @@ class ImageFieldToMediaForm extends FormBase { foreach (array_keys($view_modes) as $view_mode) { $storage = $this->entityTypeManager->getStorage('entity_view_display'); $view_display = $storage->load($entity_type . '.' . $bundle . '.' . $view_mode); $image_component = $view_display->getComponent($image_field_name); // A view display like a "Teaser" may not have the image field. In this // case the "$image_component" will be NULL. So, we should check it out. if ($image_component) { $media_component = $view_display->getComponent($media_field_name); $media_component['weight'] = $image_component['weight']; $view_display->setComponent($media_field_name, $media_component)->save(); } } // ---------- Set for Form displays ------------------------. $form_modes = $this->entityDisplayRepository->getFormModeOptionsByBundle($entity_type, $bundle); Loading