Replies: 3 comments
|
I do like this idea, being able to search for images in the r2 store using it's key, can make life a lot easer if you want to manually edit the bucket, but having an checkbox in a settings page would be nice if you don't want this feature. |
0 replies
|
Great idea, even better if it's wired up so we can use an AI agent to scan the media and automatically set alt text/file names for the images. |
0 replies
|
Overall end users with WP experience are looking to have names of files that they expect; this gets a +1 for me possibly as part of the initial setup configuration options. |
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Problem
When media is uploaded, the storage key is generated as
${ulid()}${ext}(e.g.01J7ABC...XYZ.webp) inupload-url.tsandapi/media.ts. Since the public URL is derived from the storage key (storage.getPublicUrl(key)or/_emdash/api/media/file/{key}), the descriptive originalfilenamenever reaches the URL — every image is served under an opaque ULID.Google's image SEO guidance explicitly recommends short, descriptive filenames (e.g.
my-new-black-kitten.jpgoverIMG00023.JPG) as a (light) signal for understanding image subject matter, and to avoid generic names. Today EmDash can't produce that signal in the URL.Scope: new uploads only (intentionally)
The same Google guidance recommends stable, consistent image URLs (for crawl budget and caching). Renaming the keys of existing media would change URLs and break content references, so this proposal deliberately covers new uploads only — existing keys stay untouched.
Proposal
Build the storage key from a slugified filename plus a ULID suffix for uniqueness:
SAFE_STORAGE_KEY = /^[A-Za-z0-9._-]+$/permits hyphens.slugify()helper (handles diacritics, truncation).Touch points
A single
buildStorageKey(filename)helper inmedia/, used by:packages/core/src/astro/routes/api/media/upload-url.tspackages/core/src/astro/routes/api/media.ts(direct upload)packages/core/src/astro/routes/api/import/wordpress/media.tsQuestions for maintainers
media.descriptiveKeys)?If the direction is welcome, I'm happy to open a small PR (with tests). A PoC is ready.
Disclosure: drafted with AI assistance (Cursor + Claude Opus 4.8).
All reactions