diff --git a/src/Controller/ExifSettingsController.php b/src/Controller/ExifSettingsController.php
index 435cbee..d47768f 100644
--- a/src/Controller/ExifSettingsController.php
+++ b/src/Controller/ExifSettingsController.php
@@ -8,6 +8,7 @@ namespace Drupal\exif\Controller;
 
 use Drupal;
 use Drupal\Core\Controller\ControllerBase;
+use Drupal\Core\Entity\EntityDisplayRepositoryInterface;
 use Drupal\Core\Entity\EntityInterface;
 use Drupal\Core\Entity\Entity\EntityViewDisplay;
 use Drupal\Core\Entity\Entity\EntityFormDisplay;
@@ -16,11 +17,37 @@ use Drupal\Core\Field\FieldStorageDefinitionInterface;
 use Drupal\field\Entity\FieldStorageConfig;
 use Drupal\field\Entity\FieldConfig;
 use Drupal\taxonomy\Entity\Vocabulary;
+use Symfony\Component\DependencyInjection\ContainerInterface;
 use Symfony\Component\HttpFoundation\RedirectResponse;
 use Symfony\Component\HttpFoundation\Response;
 
 class ExifSettingsController extends ControllerBase {
 
+  /**
+   * The entity display repository.
+   *
+   * @var \Drupal\Core\Entity\EntityDisplayRepositoryInterface
+   */
+  protected $entityDisplayRepository;
+
+  /**
+   * Constructs a ExifSettingsController object.
+   *
+   * @param \Drupal\Core\Entity\EntityDisplayRepositoryInterface $entity_display_repository
+   *   The entity display repository.
+   */
+  public function __construct(EntityDisplayRepositoryInterface $entity_display_repository) {
+    $this->entityDisplayRepository = $entity_display_repository;
+  }
+
+  /**
+   * {@inheritdoc}
+   */
+  public static function create(ContainerInterface $container) {
+    return new static(
+      $container->get('entity_display.repository')
+    );
+  }
 
   /**
    * button to create a vocabulary "photographies'metadata" (exif,iptc and xmp data contains in jpeg file)
@@ -221,7 +248,7 @@ class ExifSettingsController extends ControllerBase {
 
     // The teaser view mode is created by the Standard profile and therefore
     // might not exist.
-    $view_modes = Drupal::entityManager()->getViewModes($entity_type);
+    $view_modes = $this->entityDisplayRepository->getViewModes($entity_type);
     if (isset($view_modes['teaser'])) {
       $this->entity_get_display($entity_type, $type->id(), 'teaser')
         ->setComponent($machinename, array(
diff --git a/src/Plugin/Field/FieldWidget/ExifReadonlyWidget.php b/src/Plugin/Field/FieldWidget/ExifReadonlyWidget.php
index bdec96c..e784cfb 100644
--- a/src/Plugin/Field/FieldWidget/ExifReadonlyWidget.php
+++ b/src/Plugin/Field/FieldWidget/ExifReadonlyWidget.php
@@ -7,12 +7,17 @@
 namespace Drupal\exif\Plugin\Field\FieldWidget;
 
 use Drupal;
+use Drupal\Core\Entity\EntityTypeManagerInterface;
 use Drupal\Core\Field\BaseFieldDefinition;
+use Drupal\Core\Field\FieldDefinitionInterface;
 use Drupal\Core\Field\FieldItemListInterface;
 use Drupal\Core\Field\WidgetBase;
 use Drupal\Core\Form\FormStateInterface;
+use Drupal\Core\Plugin\ContainerFactoryPluginInterface;
+use Drupal\Core\Render\ElementInfoManagerInterface;
 use Drupal\exif\ExifFactory;
 use Drupal\field\Entity\FieldConfig;
+use Symfony\Component\DependencyInjection\ContainerInterface;
 
 
 /**
@@ -36,14 +41,57 @@ use Drupal\field\Entity\FieldConfig;
  *   }
  * )
  */
-class ExifReadonlyWidget extends ExifFieldWidgetBase {
+class ExifReadonlyWidget extends ExifFieldWidgetBase implements ContainerFactoryPluginInterface {
+
+  /**
+   * The entity type manager.
+   *
+   * @var \Drupal\Core\Entity\EntityTypeManagerInterface
+   */
+  protected $entityTypeManager;
+
+  /**
+   * Constructs a ExifReadonlyWidget object.
+   *
+   * @param string $plugin_id
+   *   The plugin_id for the widget.
+   * @param mixed $plugin_definition
+   *   The plugin implementation definition.
+   * @param \Drupal\Core\Field\FieldDefinitionInterface $field_definition
+   *   The definition of the field to which the widget is associated.
+   * @param array $settings
+   *   The widget settings.
+   * @param array $third_party_settings
+   *   Any third party settings.
+   * @param \Drupal\Core\Entity\EntityTypeManagerInterface $entity_type_manager
+   *   The entity type manager.
+   */
+  public function __construct($plugin_id, $plugin_definition, FieldDefinitionInterface $field_definition, array $settings, array $third_party_settings, EntityTypeManagerInterface $entity_type_manager) {
+    parent::__construct($plugin_id, $plugin_definition, $field_definition, $settings, $third_party_settings);
+    $this->entityTypeManager = $entity_type_manager;
+  }
+
+  /**
+   * {@inheritdoc}
+   */
+  public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition) {
+    return new static(
+      $plugin_id,
+      $plugin_definition,
+      $configuration['field_definition'],
+      $configuration['settings'],
+      $configuration['third_party_settings'],
+      $container->get('entity_type.manager')
+    );
+  }
+
   /**
    * {@inheritdoc}
    */
   public function formElement(FieldItemListInterface $items, $delta, array $element, array &$form, FormStateInterface $form_state) {
     $value = $items->getValue();
     $entity_type = $items->getFieldDefinition()->getTargetEntityTypeId();
-    $access = \Drupal::entityManager()->getAccessControlHandler($entity_type)->fieldAccess('view', $items->getFieldDefinition());
+    $access = $this->entityTypeManager->getAccessControlHandler($entity_type)->fieldAccess('view', $items->getFieldDefinition());
     if (!$access) {
       $element += array(
         '#type' => '#hidden',
