Image cropping in Drupal 8

slashrsm

Cropping of images has existed in Drupal for years. There are plenty of modules that attempt to solve this problem in Drupal 7 and earlier; these solutions, however, are not without their own issues. One of the main problems was a lack of cooperation. Every module implemented everything from scratch: storage, UI, image effects, etc. This resulted in a significant amount of redundant work, which is a huge problem due to the limited resources that are available. It also prevented users from replacing one solution with another. In order to do that, it would be necessary to migrate of data and reconfigure all the image styles.

To solve those problems we took slightly different approach in Drupal 8. The entire media ecosystem is now decoupled into independent components and it made sense to replicate this model in the area of cropping too.

We created Crop API, which is responsible for storage part and basic image effects. It provides clear, concise API which can be used by UI modules. Currently, we have 2 UI modules that are dependent on it and we're expecting to see more in the near future.

We will cover basic concepts behind the new architecture, explain relevant details of Crop API, list UI modules, and show them in action. We will also briefly explain how to use the Crop API as a developer of UI modules.

Session Track

Site Building

Experience Level

Beginner

Drupal Version