close
Skip to content

Add descriptive filenames for AI-generated featured images#480

Closed
dhrupo wants to merge 1 commit into
WordPress:developfrom
dhrupo:fix/402-descriptive-featured-image-filenames
Closed

Add descriptive filenames for AI-generated featured images#480
dhrupo wants to merge 1 commit into
WordPress:developfrom
dhrupo:fix/402-descriptive-featured-image-filenames

Conversation

@dhrupo
Copy link
Copy Markdown

@dhrupo dhrupo commented Apr 27, 2026

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 new ai_image_import_filename filter 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

  1. Enable the Image Generation and Editing feature.
  2. Create a new post with a title such as WordPress SEO Guide and body content.
  3. Generate a featured image from the post editor.
  4. Open the Media Library and confirm the uploaded file uses a descriptive filename like ai-generated-image-wordpress-seo-guide-<timestamp>.png.
  5. Repeat with an empty title and confirm the filename falls back to content-derived context.
  6. Repeat with no usable title or content and confirm the filename falls back to ai-generated-image-<timestamp>.png.

Ran locally:

  • npm run typecheck
  • npm run lint:js -- src/features/image-generation/components/GenerateFeaturedImage.tsx src/features/image-generation/functions/upload-image.ts src/features/image-generation/types.ts
  • php -l includes/Abilities/Image/Import_Base64_Image.php
  • php -l tests/Integration/Includes/Abilities/Image_ImportTest.php

Not run locally:

  • vendor/bin/phpunit was unavailable in this workspace.
  • vendor/bin/phpcs was unavailable in this workspace.

Changelog Entry

Fixed - Add descriptive default filenames for AI-generated featured images using post context when available.

Open WordPress Playground Preview

@github-actions
Copy link
Copy Markdown

github-actions Bot commented Apr 27, 2026

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 props-bot label.

Unlinked Accounts

The 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.

Unlinked contributors: hi0001234d.

Co-authored-by: dhrupo <dhrupo@git.wordpress.org>
Co-authored-by: dkotter <dkotter@git.wordpress.org>
Co-authored-by: jeffpaul <jeffpaul@git.wordpress.org>
Co-authored-by: kishan-ranawat <kishanranawat@git.wordpress.org>

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.

@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 27, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 69.21%. Comparing base (a04709f) to head (2fa3126).

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              
Flag Coverage Δ
unit 69.21% <100.00%> (+0.15%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@dkotter
Copy link
Copy Markdown
Collaborator

dkotter commented Apr 27, 2026

@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

@dhrupo
Copy link
Copy Markdown
Author

dhrupo commented Apr 28, 2026

Closing this in favor of #471, which is already open for #402 and follows the maintainer guidance more closely. I left the only remaining comparison note on #471 so discussion can stay in one place.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Core AI: Improve AI Generated Image Naming for Featured Images (Include AI Prefix + Context) (WP 7.0 RC)

2 participants