Skip to main content
Drupal is a registered trademark of Dries Buytaert
Release: Workflow Modeler 1.0.9 Minor update available for module modeler (1.0.9). Release: Vite 1.5.6 Minor update available for module vite (1.5.6). Release: Mautic Audiences 1.1.0 Minor update available for module mautic_audiences (1.1.0). Release: Freja eID for Drupal 1.0.2 Minor update available for module freja_eid (1.0.2). Release: FileGate 1.10.1 Minor update available for module file_gate (1.10.1). Release: MCP Sentinel 2.23.0 Minor update available for module mcp_sentinel (2.23.0). Release: Synapse helper module 3.0.9 Minor update available for module synhelper (3.0.9). Release: Synapse helper module 3.0.8 Minor update available for module synhelper (3.0.8). Module Revived: Decorative Images 1.3.6 Module decorative_images updated after 7 months of inactivity (1.3.6). Security Coverage: Pixie Dark Theme pixie_dark now has official Drupal security advisory coverage.

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

Depends on

Dependencies of the latest stable release

No dependencies recorded for this project.

Required by

Tracked projects that depend on this one

No tracked projects depend on this one yet.

Activity

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

Releases

Version Type Core Release date
1.x-dev Dev 9–11 Mar 23, 2026