Add descriptive filenames for AI-generated featured images#480
Conversation
|
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the Unlinked AccountsThe following contributors have not linked their GitHub and WordPress.org accounts: @hi0001234d. Contributors, please read how to link your accounts to ensure your work is properly credited in WordPress releases. If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message. To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## develop #480 +/- ##
=============================================
+ Coverage 69.06% 69.21% +0.15%
- Complexity 957 961 +4
=============================================
Files 60 60
Lines 4512 4535 +23
=============================================
+ Hits 3116 3139 +23
Misses 1396 1396
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
@dhrupo Thanks for the PR! Just wanted to note we already have #471 opened that is set to close #402. I'd suggest that instead of a completely separate PR to solve the same thing, review that PR and if you have comments/questions/feedback on the approach taken there, best to leave that on that PR and close this one out |

What?
Closes #402
Improves default filenames for AI-generated featured images by including post context before the timestamp, while preserving the existing fallback when no context is available.
Why?
Featured images generated through the AI flow currently land in the Media Library with generic timestamp-only filenames like
ai-generated-image-<timestamp>. That makes generated uploads harder to identify and does not reflect the post they belong to, which is the issue reported in #402.How?
The featured-image UI now passes filename context from the post title first, then stripped post content if the title is empty. The image import ability uses that context to generate filenames in the format
ai-generated-image-<context>-<timestamp>. If no usable context exists, it still falls back to the original timestamp-only filename. A newai_image_import_filenamefilter was also added so developers can override the generated default, and integration tests were added for both context-based filenames and the filter.Use of AI Tools
AI assistance: Yes
Tool(s): Codex
Model(s): GPT-5
Used for: Drafting the implementation and test updates; final changes were reviewed and edited before submission.
Testing Instructions
WordPress SEO Guideand body content.ai-generated-image-wordpress-seo-guide-<timestamp>.png.ai-generated-image-<timestamp>.png.Ran locally:
npm run typechecknpm run lint:js -- src/features/image-generation/components/GenerateFeaturedImage.tsx src/features/image-generation/functions/upload-image.ts src/features/image-generation/types.tsphp -l includes/Abilities/Image/Import_Base64_Image.phpphp -l tests/Integration/Includes/Abilities/Image_ImportTest.phpNot run locally:
vendor/bin/phpunitwas unavailable in this workspace.vendor/bin/phpcswas unavailable in this workspace.Changelog Entry