Problem/Motivation

The generated file is named from the description: ai-<slug>.<extension>. The slug keeps only a-z and 0-9 after strtolower(), so a description written in Arabic, Greek, Cyrillic, Chinese or any other non-Latin script gives an empty slug and the file falls back to ai-media.png, ai-media.mp3 and so on. Every such file then gets the same name with _0, _1 suffixes, which says nothing about the picture or clip in the file list, in the Media Library and in the URL. A French description keeps its Latin letters but loses accented ones ("phare" fine, "été" becomes "t").

Steps to reproduce

  1. On a site with Arabic, open /ar/media/add/image?ai_media=1 and describe an image in Arabic; generate.
  2. The file link reads ai-media.png; an Arabic text to speech gives ai-media.mp3.

Proposed resolution

Run the description through core's transliteration service (@transliteration, with the current language) before lower-casing and slugging, as core does for file names. Arabic "قارب خشبي" becomes "qarb-khshby", "été" becomes "ete". Keep media as the last fallback for a description that transliterates to nothing. Then pass the final name through core's file name sanitization event, so the site's File system settings (transliterate, lowercase, replacement character) and any module listening apply on top. Kernel test with an Arabic and an accented description.

Remaining tasks

  • ✅ File an issue
  • ❌ Addition/Change/Update/Fix
  • ❌ Testing to ensure no regression
  • ❌ Automated unit/functional testing coverage
  • ➖ Developer Documentation support
  • ➖ User Guide Documentation support
  • ➖ UX/UI designer responsibilities
  • ➖ Accessibility and Readability
  • ❌ Reviewed by a human
  • ❌ Code review by maintainers
  • ❌ Full testing and approval
  • ❌ Credit contributors
  • ❌ Review with the product owner
  • ✅ Update Release Notes
  • ✅ Release

User interface changes

Before (1.0.x), Horizon Aid, Default Admin: "Un café à Zürich, croquis à l'encre" saves as ai-un-caf-z-rich-croquis-l-encre.png, the accented letters dropped.

 a French description and the file link ai-un-caf-z-rich-croquis-l-encre.png

After, Horizon Aid, Default Admin: the same description saves as ai-un-cafe-a-zurich-croquis-a-l-encre.png.

 the same French description and the file link ai-un-cafe-a-zurich-croquis-a-l-encre.png

After, Varbase Starter, Gin: "Château médiéval près d'un lac, été ensoleillé" saves as ai-chateau-medieval-pres-d-un-lac-ete-ensoleille.png.

 a French description and the file link ai-chateau-medieval-pres-d-un-lac-ete-ensoleille.png

API changes

  • N/A

Data model changes

  • N/A

Release notes snippet

  • Generated file names are transliterated from the description, so Arabic and accented descriptions no longer all save as ai-media.<extension>.

AI-Generated: Yes

Issue fork ai_media-3634662

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

rajab natshah created an issue. See original summary.

rajab natshah’s picture

Issue summary: View changes
rajab natshah’s picture

Issue summary: View changes
StatusFileSize
new53.18 KB
new54.16 KB

  • rajab natshah committed c2d14942 on 1.0.x
    fix: #3634662 Transliterate the description for the generated file name
    
rajab natshah’s picture

rajab natshah’s picture

Issue summary: View changes
Status: Active » Fixed
Issue tags: +ai_media-1.0.0-rc1

✅ Released ai_media-1.0.0-rc1

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.