| 1 |
# AI Alt Text Generator |
| 2 |
|
| 3 |
## Overview |
| 4 |
|
| 5 |
The AI Alt Text Generator module for King Addons pr2. **Auto generation not working** |
| 6 |
- Enable "Auto Generate Alt Text" in settings |
| 7 |
- Check WP Cron is functioning (`wp cron event list` via WP-CLI) |
| 8 |
- Verify API key and model settings |
| 9 |
- Check queue status (see debug section below) |
| 10 |
|
| 11 |
3. **Batch uploads failing** |
| 12 |
- Queue system should handle this automatically |
| 13 |
- Check debug.log for error messages |
| 14 |
- Monitor queue status via debug page |
| 15 |
|
| 16 |
4. **API rate limits** |
| 17 |
- System automatically limits to 1 request per minute |
| 18 |
- Failed requests are retried up to 3 times |
| 19 |
- Check OpenAI usage dashboard for rate limit issues |
| 20 |
|
| 21 |
5. **API errors** |
| 22 |
- Check OpenAI account balance ($5 minimum required) |
| 23 |
- Verify API key is valid |
| 24 |
- Ensure model supports vision (gpt-4o, gpt-4-vision-preview) |
| 25 |
|
| 26 |
### Debug Mode |
| 27 |
|
| 28 |
To enable debug monitoring: |
| 29 |
1. Include `debug-functions.php` in your theme's functions.php |
| 30 |
2. Go to King Addons > Alt Text Debug |
| 31 |
3. Monitor queue status and process manually if needed |
| 32 |
|
| 33 |
#### Debug Information |
| 34 |
- Queue status (pending, processing, next run) |
| 35 |
- Individual image retry counts |
| 36 |
- Manual queue processing |
| 37 |
- Queue clearing optionsmatic and manual alt text generation for images using OpenAI's vision capabilities. |
| 38 |
|
| 39 |
## Features |
| 40 |
|
| 41 |
- **Manual Generation**: Add "Generate" buttons in Media Library for on-demand alt text creation |
| 42 |
- **Auto Generation**: Automatically generate alt text when new images are uploaded |
| 43 |
- **Media Library Integration**: Custom column showing alt text status |
| 44 |
- **Modal Integration**: Buttons in media editing modals |
| 45 |
- **Settings Control**: Toggle features individually in AI Settings |
| 46 |
|
| 47 |
## Settings |
| 48 |
|
| 49 |
Navigate to **King Addons > AI Settings** to configure: |
| 50 |
|
| 51 |
### AI Alt Text Button |
| 52 |
- **Enable/Disable**: Show "Generate" button in Media Library |
| 53 |
- **Location**: Media Library list view and modal windows |
| 54 |
- **Function**: Manual alt text generation for existing images |
| 55 |
|
| 56 |
### Auto Generate Alt Text |
| 57 |
- **Enable/Disable**: Automatically generate alt text for new uploads |
| 58 |
- **Method**: Queue-based processing with retry logic |
| 59 |
- **Timing**: Processed every minute via WP Cron |
| 60 |
- **Reliability**: 3 retry attempts per image, rate limiting to respect API limits |
| 61 |
|
| 62 |
## Requirements |
| 63 |
|
| 64 |
- OpenAI API key configured in King Addons AI Settings |
| 65 |
- At least one alt text feature enabled |
| 66 |
- Vision-capable OpenAI model (gpt-4o, gpt-4-vision-preview, etc.) |
| 67 |
|
| 68 |
## File Structure |
| 69 |
|
| 70 |
``` |
| 71 |
includes/extensions/alt-text-generator/ |
| 72 |
├── Alt_Text_Generator.php // Main PHP class |
| 73 |
├── alt-text-media.js // JavaScript for UI interactions |
| 74 |
└── alt-text-styles.css // Styling for buttons and UI |
| 75 |
``` |
| 76 |
|
| 77 |
## Usage |
| 78 |
|
| 79 |
### Manual Generation |
| 80 |
1. Go to Media Library |
| 81 |
2. Find images without alt text |
| 82 |
3. Click "Generate" button in the "AI Alt Text" column |
| 83 |
4. Alt text will be generated and saved automatically |
| 84 |
|
| 85 |
### Auto Generation |
| 86 |
1. Enable "Auto Generate Alt Text" in AI Settings |
| 87 |
2. Upload new images to Media Library (single or batch) |
| 88 |
3. Images are added to processing queue |
| 89 |
4. Queue is processed every minute automatically |
| 90 |
5. Failed generations are retried up to 3 times |
| 91 |
|
| 92 |
## Queue System |
| 93 |
|
| 94 |
### How It Works |
| 95 |
- **Queue-based Processing**: Images are added to a queue instead of immediate processing |
| 96 |
- **Rate Limiting**: Only 1 image processed per minute to respect API limits |
| 97 |
- **Retry Logic**: Failed generations are retried up to 3 times |
| 98 |
- **Batch Upload Support**: Handles multiple simultaneous uploads reliably |
| 99 |
|
| 100 |
### Monitoring |
| 101 |
- Queue status can be monitored via debug page (if enabled) |
| 102 |
- Processing logs are written to WordPress debug.log |
| 103 |
- Automatic cleanup on plugin deactivation |
| 104 |
|
| 105 |
## API Integration |
| 106 |
|
| 107 |
- **Endpoint**: OpenAI Chat Completions API |
| 108 |
- **Model**: Uses the text model from AI Settings (gpt-4o recommended) |
| 109 |
- **Image Format**: Base64 encoded images sent as data URIs |
| 110 |
- **Detail Level**: Low (for faster processing) |
| 111 |
- **Max Tokens**: 50 (for concise alt text) |
| 112 |
- **Character Limit**: 125 characters maximum |
| 113 |
|
| 114 |
## Troubleshooting |
| 115 |
|
| 116 |
### Common Issues |
| 117 |
|
| 118 |
1. **No buttons showing** |
| 119 |
- Check if "AI Alt Text Button" is enabled in settings |
| 120 |
- Verify OpenAI API key is set |
| 121 |
|
| 122 |
2. **Auto generation not working** |
| 123 |
- Enable "Auto Generate Alt Text" in settings |
| 124 |
- Check WP Cron is functioning |
| 125 |
- Verify API key and model settings |
| 126 |
|
| 127 |
3. **API errors** |
| 128 |
- Check OpenAI account balance ($5 minimum required) |
| 129 |
- Verify API key is valid |
| 130 |
- Ensure model supports vision (gpt-4o, gpt-4-vision-preview) |
| 131 |
|
| 132 |
### Debug Information |
| 133 |
|
| 134 |
Check browser console for JavaScript errors and WordPress debug logs for PHP errors. |
| 135 |
|
| 136 |
## Changelog |
| 137 |
|
| 138 |
### v1.0.0 |
| 139 |
- Initial implementation |
| 140 |
- Manual generation buttons |
| 141 |
- Auto generation for new uploads |
| 142 |
- Settings integration |
| 143 |
- Media Library column |
| 144 |
- Modal integration |
| 145 |
|