Drupal is a registered trademark of Dries Buytaert
Release: Paragraphs 8.x-1.23 Minor update available for module paragraphs (8.x-1.23). Release: AI (Artificial Intelligence) 1.4.6 Minor update available for module ai (1.4.6). Release: AI (Artificial Intelligence) 1.3.11 Minor update available for module ai (1.3.11). Release: Search and Replace Scanner 2.0.0 Major update available for module scanner (2.0.0). Release: Chosen 5.0.7 Minor update available for module chosen (5.0.7). Release: Dynamic Entity Reference 3.2.3 Minor update available for module dynamic_entity_reference (3.2.3). Release: AI Agents 1.3.3 Minor update available for module ai_agents (1.3.3). Release: Lionbridge translation provider 9.4.7 Minor update available for module lionbridge_translation_provider (9.4.7). Usage Milestone: Media entity Twitter Module media_entity_twitter crossed 10,000 active installs. Module Revived: Message 8.x-1.9 Module message updated after 17 months of inactivity (8.x-1.9).

This module validates uploaded image files against a configurable list of allowed MIME types, helping to ensure only expected image formats are accepted. It offers flexible controls to block uploads, log violations, display user-facing errors, and send notification emails when disallowed image MIME types are detected.

The Image MIME Validator module validates uploaded image files against a configurable list of allowed MIME types. It helps ensure that only expected image formats are accepted and provides flexible controls to block uploads, log violations, display user-facing errors, and send notification emails when disallowed image MIME types are detected.

Features

  • Allowed MIME list
Configure a newline-separated list of allowed image MIME types (for example, image/jpeg, image/png).
  • Image-only enforcement
Validation is applied only when the detected MIME type starts with image/.
  • Upload blocking
Optionally block image uploads whose detected MIME type is not included in the allowed list.
  • Watchdog logging
Optionally log details of invalid image uploads (file information, file path, site URL, detected MIME type) to the Drupal log.
  • End-user error messages
Optionally display a detailed error message to the uploader when an invalid image upload is blocked.
  • Email notifications
Optionally send notification emails to a configurable list of recipients when an invalid image upload is detected.
  • Per-language error text
Configure localized error message text per language through the module’s configuration UI.

Installation

  1. Download and install the module as you would any other Drupal module
  2. Enable the module from the Extend page: /admin/modules

Configuration

  1. Navigate to the configuration page:
    /admin/config/media/image-mime-validator
  2. Configure the following settings:
    • Allowed MIME types (allowed_mime_types)
    • Newline-separated list of permitted image MIME types.
    • Block invalid image uploads (image_mime_validator_block)
    • When enabled, image uploads with disallowed MIME types are blocked.
    • Log invalid image uploads (image_mime_validator_log)
    • When enabled, invalid uploads are written to the Drupal log.
    • Show error message on invalid uploads (image_mime_validator_show_error_message)
    • Displays an error message to the uploader when an upload is blocked.
    • Email on invalid uploads (image_mime_validator_email)
    • Sends a notification email when an invalid image upload is detected.
    • Notification recipients (image_mime_validator_notification_recipients)
    • Comma-separated list of email addresses. Entries are validated for correct syntax.
    • Error message per language (label.image_mime_validator_error_label.[langcode])
    • Optional language-specific error message text.

The module does not define custom permissions. It reuses existing file and media permissions provided by Drupal. Access to the configuration form is governed by standard Drupal configuration permissions.

Usage

  1. Enable and configure the module.
  2. The validator automatically runs on image uploads where the Image MIME Validator constraint is applied.
  3. If an uploaded file:
    • Has a detected MIME type starting with image/, and
    • Is not included in the allowed MIME list,
    • then, based on configuration:
    • The upload may be blocked.
    • The incident may be logged.
    • Notification emails may be sent.
    • An error message may be shown to the uploader.

Technical Details

  • Configuration storage
    Settings are stored under image_mime_validator.settings.
  • Validation constraint
    Implemented via:
    • ImageMimeValidationConstraint
    • ImageMimeValidationConstraintValidator
  • Validator behavior
    • Resolves the real file path using file_system.realpath
    • Detects the actual MIME type using mime_content_type()
    • Applies validation only to MIME types beginning with image/
    • Uses Drupal services for:
      • Logging
      • Messaging
      • Language management
      • Configuration
      • Request handling
      • Mail delivery

Activity

Tracked releases
1
Tracked since
Mar 2026
Latest release
4 months ago
Releases (12 mo)
1 ▲ from 0
Maintenance
Active

Releases

Version Type Release date
1.x-dev Dev Mar 23, 2026