Drupal is a registered trademark of Dries Buytaert
Search API Solr 4.4.0 Minor update available for module search_api_solr (4.4.0). Page Manager 8.x-4.0 Major update available for module page_manager (8.x-4.0). Trash 3.1.0-beta2 New beta version released for module trash (3.1.0-beta2). Commerce AutoSKU 3.0.1 Minor update available for module commerce_autosku (3.0.1). Custom Field 4.0.10 Minor update available for module custom_field (4.0.10). Alternative login ID & display names 2.0.12 Minor update available for module alt_login (2.0.12). EntityReference UUID 3.0.1 Minor update available for module entity_reference_uuid (3.0.1). LocalGov Publications Importer 1.1.1 Minor update available for module localgov_publications_importer (1.1.1). Configuration Override Warn 8.x-1.6 Module config_override_warn updated after 10 months of inactivity (8.x-1.6). Table Alternate Rows Module table_altrow crossed 1,000 active installs.

This project uses AI to automatically check uploaded images for inappropriate content like nudity, sexually suggestive material, or graphic violence. It blocks any images that are not classified as "safe" during the upload process, helping to maintain content standards across your site.

Validates uploaded images on the Media: Image bundle using a vision-capable AI provider. Blocks content that falls outside the "Safe" tier of Flickr-style safety levels — nudity, sexually suggestive material, gore, graphic violence, and graphic medical imagery — at upload time, across the admin UI, JSON:API, and programmatic saves.

Recipes Applied

Modules and Themes Installed

Requirements

  • Drupal 10.3 or newer
  • AI module 1.3 or newer (provides the verifySetupAi config action)
  • A configured default provider for the chat_with_image_vision operation type at /admin/config/ai/settings → Default Providers. Any vision-capable provider works (OpenAI GPT-4o, Anthropic Claude 3.5 Sonnet, Google Gemini 1.5 Pro, etc.).

If chat_with_image_vision has no default model configured, the recipe apply will abort cleanly with a message from the AI module's preflight check.

Installation

Add the recipe with the following Composer command:

composer require drupal/ai_recipe_validations_image_safety

What it does

  • Creates a Field Validation rule set on the Media: Image bundle's field_media_image field.
  • Runs the AI image constraint on every image upload, classifying the image into Safe / Moderate / Restricted tiers.
  • Blocks anything outside the Safe tier with a clear error message to the editor.
  • Catches uploads from the admin UI, the Media Library, JSON:API posts, migrations, and programmatic $entity->save() calls.

Adjusting the threshold

The default behavior blocks both Moderate and Restricted content. To allow Moderate content (mature but not explicit) and block only Restricted (explicit / graphic), edit the ai_image_safety rule at Structure → Field Validation → AI image safety (Media: Image) and update the prompt's decision block. Full instructions are in the project README.

Cost note

Every image upload triggers one vision-model API call. Bulk migrations, imports, or high-volume user upload flows will incur proportional cost. Test with your provider's pricing before rolling out to production.

Bugs and Feedback

If you encounter any bugs or have feedback about this recipe, please file an issue in the project issue queue.

Credits

Developed as part of the AI Initiative. See the originating issue: #3585696.

Activity

Total releases
3
First release
Apr 2026
Latest release
2 weeks ago
Releases (12 mo)
3 ▲ from 0
Maintenance
Active

Release Timeline

Releases

Version Type Release date
1.0.1 Stable Jul 8, 2026
1.0.0 Stable Jul 8, 2026
1.0.x-dev Dev Apr 27, 2026