https://github.com/zerobytecodecom/zerobytecode-ai-featured-image-generator
One-click generate and set WordPress post featured image using OpenAI's Dalle 3 AI.
https://github.com/zerobytecodecom/zerobytecode-ai-featured-image-generator
dall-e dall-e-3 dall-e-api dall-e3 openai-api php wordpress wordpress-plugin
Last synced: about 1 month ago
JSON representation
One-click generate and set WordPress post featured image using OpenAI's Dalle 3 AI.
- Host: GitHub
- URL: https://github.com/zerobytecodecom/zerobytecode-ai-featured-image-generator
- Owner: zerobytecodecom
- License: gpl-2.0
- Created: 2024-08-04T16:57:31.000Z (10 months ago)
- Default Branch: main
- Last Pushed: 2024-08-05T07:11:59.000Z (10 months ago)
- Last Synced: 2025-02-13T11:54:29.171Z (3 months ago)
- Topics: dall-e, dall-e-3, dall-e-api, dall-e3, openai-api, php, wordpress, wordpress-plugin
- Language: PHP
- Homepage: https://zerobytecode.com/create-a-wordpress-plugin-to-generate-featured-images-using-ai/
- Size: 11.7 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# zerobytecode-ai-featured-image-generator
One-click generate and set WordPress post featured image using OpenAI's Dall-E 3.---
This plugin can help you generate a featured image directly from the post editor screen just with one click.The plugin has a settings options with two fields:
- OpenAI API Key
- Content Template (the prompt)By default, the plugin will use the post's excerpt as part of the prompt. To change the user input from post's excerpt, just change `$excerpt` in the following line to whatever you like, whether static or dynamic value like post's title, etc.
```
// Generate image prompt using OpenAI chat completions
$prompt_response = wp_remote_post(
'https://api.openai.com/v1/chat/completions',
[
'headers' => [
'Content-Type' => 'application/json',
'Authorization' => 'Bearer ' . $api_key,
],
'body' => wp_json_encode([
'model' => 'gpt-3.5-turbo',
'messages' => [
[
'role' => 'system',
'content' => sanitize_textarea_field($content_template),
],
[
'role' => 'user',
'content' => sanitize_text_field($excerpt),
],
],
]),
'timeout' => 60,
]
);
```You can read the complete guide to [generate featured image using Dall-E 3](https://zerobytecode.com/create-a-wordpress-plugin-to-generate-featured-images-using-ai/).