Screenshot showing the image style selector mechanism below an image field

Creating pages with consistently sized, scaled or rotated images can be accomplished by applying an image style. In this way you can ensure that e.g. profile pictures all have the same dimension or that high resolution images are automatically scaled down to a more appropriate size. With the great advantage that original images are still available, so for instance reusing images in an overview requiring a different size is easily done.

Natively, you can only specify which image style to use on a content type basis (i.e., entity's bundle). To overcome this limitation, this module allows to select which image style should be applied per image (field). Site administrators can specify which image styles would be appropriate for the content editor to select and this module makes sure that the selected image style is applied accordingly.

Requirements

This module requires that Drupal core's Image module is enabled.

Usage

  1. Installing this module is like any other regular Drupal module. For more information see the documentation on installing modules.
  2. Normally, you should first add an Image field to a node. You could also use any other entity that is fieldable (such as a Field collection entity). And provide some image styles that could be applied to the image. For more information see documentation on how to use the Image field
  3. After setting up the Image field and image styles, add a field of the type Image Style Selector (to the same entity).
  4. On the instance settings page of the Image Style Selector field, select the image field where the image style should be applied to and mark the image styles that should be available for the content editor.
  5. To prevent that the images are shown twice, set the Image field to hidden on the entity's manage display tab.
  6. That's all there is, you can now add content and select the appropriate style that should be applied to the uploaded image.

Similar projects

  • Formatter Field, provides a field that allows to change the formatter and formatter settings of another field. As a result, this generic solution allows to dynamically format an Image field (i.e., change the image style to use for the uploaded image). However, the content editor is able to choose all formatter settings and can use any available image style. To keep things simple (for the content editor), the Image Style Selector field only shows the settings that are needed (for the content editor).
Supporting organizations: 
funding the development

Project Information

Downloads