how to propose when editing content 2 possible media style for an image field?

Solutions

You could add a separate select dropdown textfield with two options, which are the image styles you'd like, and if they select the alternate one, update the field in hook_entity_view.

 function mymodule_entity_view(array &$build, EntityInterface $entity, EntityViewDisplayInterface $display, $view_mode) {
   if ($entity->getEntityType()->id() == 'node' && $entity->bundle() == 'article' && !$entity->field_image_style->isEmpty()) {
     $style = $entity->field_image_style->getValue()[0]['value'];
     $build['field_image'][0]['#image_style'] = $style;
   }
 }
Tags: Drupal 8 / Media

Similar questions

How i can add new fancybox-style (theme) for display uploaded image in WYSIWYG / CKEditor with Media module?
When I upload new image with Media Browser (WYSIWYG + CKEditor + Media), I see themes: original, small, large... How i can add my own template to this list for fancybox? Maybe already have a module for this theme?
How to set image style for media browser in node edit form?
I am using the media browser that is part of the media module to upload or select images on a node edit form. I an image is already uploaded it is shown in the edit form in it's original size. If the image is large this makes the whole edit form unusable. Where can I set the images style, that is used for the edit form?
Dedicated image style for media gallery teaser
Is there any possiblity to define another dedicated image style for the teaser of a media gallery node only? I can change the default gallery thumbnail image style but this has also effect on the galleries overview page. Because I like to create an image slider on the front page with the 5 newest galleries but need the image in another format then ...
Editing media for content editor results in a 404
We have a custom role, location_editor, which is assigned to users who can only manage media and one content type. These are the role's media permissions. And if the user now tries to enter any valid media edit url (for example /media/35/edit - which does exist and was created by him), the result is a 404. The admin user can edit it just fine. The ...
How to display a field when a media is uploaded to the media library field?
I have block settings form where I have a media library field. but my ajaxCallback method never called and the test field is always hidden.
Post becomes unpublished upon editing it and no additional date values or image uploads are possible
I have a custom content with a large number of multivalue date fields (around 200-300 values). I created a node and added a large number of dates. When subsequently editing the post, the following occurs: I would like to have some instructions as to how to debug this situation. PS: The site is hosted on Hostgator.com.

Also ask

We use cookies to deliver the best possible experience on our website. By continuing to use this site, accepting or closing this box, you consent to our use of cookies. To learn more, visit our privacy policy.