crop_media_on_upload
Automatically generate separate media entities for different crop selections defined during the initial image upload.
Introduction:
Crop Media on Upload streamlines the editorial workflow for sites requiring multiple aspect ratios (e.g., Square, Hero, Thumbnail) for a single image asset.
While the use of Image Styles will cover many scenarios, based on a single source image, some projects may require more specific targeting of the cropping/resizing of images and, potentially, multiple different shapes and sizes of an image for different uses.
Traditionally, this would mean using third-party image editing tools first to create the correct size/shape images and then having to upload each one to your Drupal site as its own Media entity.
This module allows users to upload a single original image, define their crop shapes (and, optionally, specific sizes) and then use the ImageCropWidget module to define the different crops on upload. It then automatically handles the creation of independent media entities for each crop/size variation.
Key Features:
- Automatic Multi-Crop Generation: Creates new, separate media entities for every defined and selected crop type (e.g., Square, 16:9, Portrait) immediately upon upload.
- Resize on upload: Optionally set fixed sizes for your generated crop versions, including multiple sizes per crop style.
How it Works:
- Configure: Set which of your image-based Media type(s) you wish to use the functionality on and select which Crop Types (from the Crop API) should be enabled for that bundle.
- Upload: When a user uploads an image to a configured Media type, they are presented with the selected cropping tools.
- Process: Upon saving, the module generates a unique, cropped image file for every selection and creates a new Media entity for each, using the original title plus the crop label (e.g., "My Image - Square"). Users can choose whether to also keep the original image or just retain the cropped versions.
Requirements:
- Media (Core)
- Crop API
- Image Widget Crop
Installation & Configuration:
- Install the module as usual via Composer.
- Set up your crop types via /admin/config/media/crop
- Navigate to /admin/config/media/crop-media-on-upload.
- Select the Media types you wish to enable.
- Map the image field and select the desired crop styles for each type.
- (Optional) Set a fixed size/sizes for the crop image to be resized to after cropping.
- (Optional) Set a global suffix for original images or enable the "Don't keep the original image" setting for specific bundles.
Note for Administrators: This module dynamically manages the form display for configured image fields. While active, manual changes to the widget type for those fields in the "Manage Form Display" tab will be overridden to ensure consistent functionality.