Skip to main content
Drupal is a registered trademark of Dries Buytaert
Release: OpenID Connect / OAuth client 3.0.0-alpha9 New alpha version released for module openid_connect (3.0.0-alpha9). Release: Timelinr 1.0.1 Minor update available for module timelinr (1.0.1). Usage Milestone: Simplify Module simplify crossed 10,000 active installs. Usage Milestone: Views Reference Filter Module entityreference_filter crossed 10,000 active installs. Usage Milestone: Dropdown Language Module dropdown_language crossed 10,000 active installs. Usage Milestone: Paragraphs Browser Module paragraphs_browser crossed 10,000 active installs. Usage Milestone: OpenAPI Module openapi crossed 10,000 active installs. Usage Milestone: Decoupled Router Module decoupled_router crossed 10,000 active installs. Usage Milestone: Time Field for Drupal 8+ Module time_field crossed 10,000 active installs. Module Revived: Entityqueue Buttons 1.1.2 Module entityqueue_buttons updated after 8 months of inactivity (1.1.2).

Media Library Importer

774 sites Security covered Drupal 9–11
View on drupal.org

This module imports files from a directory into Drupal's media library. It can handle images and other file types, including unmanaged files, and prevents duplicate entries by checking for existing media entities.

A module to import media files from public directory into media library.

There are a lot of tutorials on how to import file entities into media galleries using migration tools.
But they are neither practical nor easy. This simple module imports your previously uploaded images into media library.

This module can also import unmanaged files. If you simply upload a folder containing images (and subfolders containing other image files) all the image files in the uploaded folders will be converted to media entities.

LATEST NEWS:

  • Now non-image files (pdf,docx,xlsx,pptx amd mp4 files) can also be imported.
  • Since release 2.1.1 this module also embeds the Media Image Exif Importer (media_image_exif_importer) submodule, as Drupal 11 enhancement / upgraded fork of its original Media Entity Image EXIF module which looks declared abandoned by its maintainers and frozen within its compatibility with Drupal 10.

How it works

  1. The module scans the configured source folder, matching files to media types by their extension.
  2. For each matched file, a File entity is loaded (if already managed) or created.
  3. Items are dispatched to a queue as bundle / file / extra fields triples.
  4. The queue worker creates a Media entity for each item, attaching the file to the correct source field. If a matching Media entity already exists for that file, the item is skipped — guaranteeing no duplicates across runs.
  5. If Immediately process queue on submit is enabled (the default), the queue is drained as a batch process right after the import form is submitted. Otherwise, items remain in the queue for cron or manual processing via the Queue UI.

Requirements

The module requires the Drupal core Media and Media Library modules.

Since 2.0 it requires additional Queue Ui
contrib module to properly process queue with batch imports.

Instructions

  • Require the module with composer, or unpack the code base in the *modules* folder, currently in the root of your Drupal installation.
  • Enable the module in '/admin/modules', or using the following drush command: drush en media-library;
  • Then, visit '/admin/config/media/media-library-importer-configuration' to configure the module;
  • Last, visit '/admin/config/media/media-library-importer/import' for the actual import operation;
  • It is possible to import Media (according to Media Library Import settings) using the following drush command drush media-library:import or drush mli (alias);
  • It is possible to implement a hook_cron job and run automatic Media Library Imports (incrementally uploading new files in the same source folders locations). More info on this in the Readme.md file;

For developers

You can attach additional field values to media entities at import time by implementing
hook_alter_media_library_importer_media_extra_fields() in your custom module.
See media_library_importer.api.php for the full signature and usage example.

Note

You can run import as many times as you like without occurring into duplications. Once created, Media entities will not be re-created if already existing with the same source file.

Depends on

Dependencies of the latest stable release

  • Queue UI
  • media Drupal core
  • media_library Drupal core

Required by

Tracked projects that depend on this one

No tracked projects depend on this one yet.

Activity

Tracked releases
6
Tracked since
Dec 2024
Latest release
1 year ago
Releases (12 mo)
0 ▼ from 6
Maintenance
Dormant

Release Timeline

Releases

Version Type Core Release date
2.1.5 Stable 9–11 Jun 1, 2025
2.1.4 Stable 9–11 May 31, 2025
2.1.3 Stable 9–11 Mar 6, 2025
2.1.2 Stable 9–11 Jan 12, 2025
2.1.1 Stable 9–11 Dec 24, 2024
2.1.0 Stable 9–11 Dec 18, 2024