How to render a media entity image (that uses a focal point image style) inside a paragraph twig file? Originally I used a typical image field in my paragraph, now with the new updates for the media module I would like to use the image library to upload and reuse media entity images. I use focal point for my image styles, in the paragraph I use, the user can choose between a couple of image styles.

preprocess code for passing image styles to twig template:

function tekst_en_afbeelding_preprocess_paragraph__tekst_en_afbeelding(&amp;$variables) {
    if (isset($variables['elements']['field_image']['#items'])) {
      $variables['img_223_x_308'] = ImageStyle::load('223_x_308')-&gt;buildUrl($variables['elements']['field_image']['#items']-&gt;entity-&gt;uri-&gt;value);
      $variables['img_326_x_450'] = ImageStyle::load('326_x_450')-&gt;buildUrl($variables['elements']['field_image']['#items']-&gt;entity-&gt;uri-&gt;value);
      $variables['img_560_x_308'] = ImageStyle::load('560_x_308')-&gt;buildUrl($variables['elements']['field_image']['#items']-&gt;entity-&gt;uri-&gt;value);
      $variables['img_1280_x_703'] = ImageStyle::load('1280_x_703')-&gt;buildUrl($variables['elements']['field_image']['#items']-&gt;entity-&gt;uri-&gt;value);
  }
}


This code does not work anymore for the media entity image.what do I need to change for this to work?
You'll run into troubles with this technique, because Media images are entities on their own, and have their own cache settings. So if you change the image style on paragraph level, the embedded media image will not know anything of this and instead returns the first, cached size.

Instead create multiple display view modes for your media entities, and let your editors choose the view mode on paragraph level. Below is the code I'm using in my own projects

function wtfrontend_base_preprocess_paragraph__image(array &amp;$variables) {
  $paragraph = $variables['paragraph'];

  if ($paragraph-&gt;hasField('field_image_viewmode_image')) {
    $imageViewMode =  $paragraph-&gt;field_image_viewmode_image-&gt;value;
    if (isset($variables['content']['field_image']['0']['#view_mode'])) {
      $variables['content']['field_image']['0']['#view_mode'] = $imageViewMode; 
      unset($variables['content']['field_image']['0']['#cache']['keys']);
    }
  }
}


Render the image normally with {{ content.field_image }}