How to generate different image styles at upload

by John   Last Updated October 18, 2019 22:07 PM - source

I'm using Drupal 8. Is there a hook for generating image from image style or better one module?For example. I upload an image. When image is displayed for the first time, drupal generates image style. Can I hook to that event somehow, at best when uploading the image?

Tags : 8

Answers 1

You don't need to write code to generate image styles in Drupal.
This functionality is provided by the Image module in Drupal core.

From the documentation:

To create or change image styles:
1. Choose Administration > Configuration > Media > Image styles.
2. Add or select a style to edit its settings.
3. When configuring styles you can add effects: crop, scale, resize, rotate, and desaturate (other contributed modules provide additional effects). For example, by combining effects as crop, scale, and desaturate, you can create square, grayscale thumbnails.
4. Save the settings.

To start using the defined styles they must be assigned to the display of a content type.

For each display (e.g. "default" or "teaser"), a different style can chosen.

To assign a style:

  1. Choose Administer > Structure > Content types > Manage display.
  2. Choose the display (e.g. "default" or "teaser") via the tab buttons.
  3. Click the gear wheel button to choose an image style; you are also able to link the image to the node.
  4. Save the settings.
  5. Check the content that contains the image style in question to see your new styles at work.
October 18, 2019 21:42 PM

Related Questions