Add support for image alt text when importing media image from CSV

Created on 18 June 2025, 16 days ago

Problem/Motivation

I needed to use the Media import type provided by the module, and I noticed that it currently doesn't import the alternative text for images from the CSV file — for example, from a column like field_media_image_alt.

The column name can be anything, as long as it ends with _alt, since it's dynamically matched to the corresponding image field.

Proposed resolution

Adds logic to the add() method of the CSV Importer plugin to allow setting the alt attribute on image fields within Media entities.

The logic looks for any CSV column that ends with _alt and matches it with the corresponding image field (e.g., field_media_image + _alt). If found, the field is constructed as an array containing both target_id and alt.

Feature request
Status

Active

Version

2.0

Component

Code

Created by

🇪🇸Spain pau.sanz

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

Production build 0.71.5 2024