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
- On a site with Arabic, open
/ar/media/add/image?ai_media=1and describe an image in Arabic; generate. - The file link reads
ai-media.png; an Arabic text to speech givesai-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.

After, Horizon Aid, Default Admin: the same description saves as 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.

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
| Comment | File | Size | Author |
|---|---|---|---|
| #6 | K40-real-vs1-gin-en-branch-fr-after.png | 169.05 KB | rajab natshah |
| #6 | K40-real-ha-defaultadmin-en-branch-fr-after.png | 168.73 KB | rajab natshah |
| #6 | K40-real-ha-defaultadmin-en-1x-fr-before.png | 140.71 KB | rajab natshah |
| #4 | K40-after.png | 54.16 KB | rajab natshah |
| #4 | K40-before.png | 53.18 KB | rajab natshah |
Issue fork ai_media-3634662
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
Comment #3
rajab natshahComment #4
rajab natshahComment #6
rajab natshahComment #7
rajab natshah✅ Released ai_media-1.0.0-rc1