You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+30-2Lines changed: 30 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -26,7 +26,7 @@ I also included an `alter:generate` [CLI command](https://github.com/getkirby/cl
26
26
27
27
#### CLI Arguments
28
28
29
-
-`--prompt` / `-p` - Custom prompt for generating alt texts (default: `"You are an accessibility expert writing alt text. Write a concise, short description in one to three sentences. Start directly with the subject - NO introductory phrases like "image of", "shows", "displays", "depicts", "contains", "features" etc. Return the alt text only, without any additional text or formatting."`)
29
+
-`--prompt` / `-p` - Custom prompt for generating alt texts (overrides the configured prompt)
30
30
-`--overwrite` - Overwrite existing alt texts (default: `false`)
31
31
-`--dry-run` - Preview changes without updating files (default: `false`)
32
32
-`--verbose` - Show detailed progress information (default: `false`)
'apiKey' => 'your-claude-api-key', // Set your Claude API key here
60
+
'prompt' => 'Your custom prompt', // Optional: Custom prompt for alt text generation
60
61
]
61
62
];
62
63
63
64
```
64
65
65
66
Get your Claude API key from the [Anthropic Console](https://console.anthropic.com/).
66
67
68
+
### Custom Prompt Configuration
69
+
70
+
The prompt option can be either a string or a callback function that receives the image file as a parameter. The default is:
71
+
72
+
```php
73
+
'prompt' => function ($file) {
74
+
$prompt = 'You are an accessibility expert writing alt text. Write a concise, short description in one to three sentences. Start directly with the subject - NO introductory phrases like "image of", "shows", "displays", "depicts", "contains", "features" etc.';
75
+
$prompt .= ' The image is on a page called "' . $file->page()->title() . '".';
76
+
$prompt .= ' The site is called "' . $file->site()->title() . '".';
77
+
$prompt .= ' Return the alt text only, without any additional text or formatting.';
78
+
79
+
return $prompt;
80
+
}
81
+
```
82
+
83
+
You can override this with your own string or callback:
84
+
85
+
```php
86
+
// Simple string prompt
87
+
'prompt' => 'Describe this image concisely for accessibility purposes.'
88
+
89
+
// Custom callback with different context
90
+
'prompt' => function($file) {
91
+
return 'Describe this image. Context: "' . $file->page()->text()->excerpt(100) . '"';
0 commit comments