Check max length of media image alt text

Created on 29 April 2025, about 1 month ago

Problem/Motivation

Getting following error on saving translation of media image alt text which exceeds the database max length.
Drupal\Core\Entity\EntityStorageException: SQLSTATE[22001]: String data, right truncated: 1406 Data too long for column 'thumbnail__alt' at row 4: INSERT INTO "media_field_data" ("mid", "vid", "bundle", "langcode", "status", "uid", "name", "thumbnail__target_id", "thumbnail__alt", "thumbnail__title", "thumbnail__width", "thumbnail__height", "created", "changed", "default_langcode", "revision_translation_affected", "content_translation_source", "content_translation_outdated", "publish_on", "unpublish_on", "publish_state", "unpublish_state")

Steps to reproduce

Add a media field with Image type with alt enabled.
Create a page.
Translate using tmgmt.
Add text into alt field in translation more than 512 characters.

Proposed resolution

Validate the max length before submitting.

Remaining tasks

Review.

Feature request
Status

Active

Version

1.0

Component

Miscellaneous

Created by

🇮🇳India sakthi_dev

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