Auto Featured Image by Post Types Using Robolly API and Templates
WPCodeBox
This snippet uses Robolly Templates and API to generate Featured Images for a Specific Post Type. It has WP Admin page inside Settings > AFI—Robolly.
Conditions:
- Requires Robolly Template to be done
- Requires Robolly API key
- A post with a
publishedstatus, only if there is NO featured image already attached - Setup credentials in Settings > AFI — Robolly
Operation:
- Set up a Template in Robolly
- Copy the Template ID and Robolly API Key
- Set up the preferences
- Now go to a published post or page
- Make sure there are no existing-featured images is set to the post
- Press Save — wait for it to work
- Refresh the post editor to see the new featured image
Works with:
- WP CodeBox
- FluentSnippets
- Other Code Snippets Plugins
Additional Snippets
CHANGELOG:
Version 1.2 (2026-01-15)
- Added support for extracting first image from post content (per post-type control)
- Added minimum image width validation (600px default, configurable per post-type)
- Added image parameter name configuration for Robolly templates (per post-type)
- Added automatic image dimension detection
- Added support for sending images to Robolly API via URL parameter
- Enhanced error logging for image extraction process
- Added fallback behavior when no suitable image is found
- Added version management and automatic settings migration
- Per post-type configuration for image extraction feature
- Added manual save/update support with duplicate prevention
- Plugin now works on save/update events, not just publish
- Smart tracking prevents multiple generations for same post
- Auto-reset generation flag when featured image is manually deleted
- Allow regeneration by simply deleting featured image and saving again
Version 1.1
- Added image metadata generation settings
- Added support for custom post types
- Improved error handling and retry logic
Version 1.0
- Initial release
Copy the code and paste it inside your favorite code-snippet plugin.
View on GitHub