Skip to content

Commit eadbfc6

Browse files
committed
Mention new option in README
1 parent 943d074 commit eadbfc6

File tree

1 file changed

+30
-2
lines changed

1 file changed

+30
-2
lines changed

README.md

Lines changed: 30 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ I also included an `alter:generate` [CLI command](https://github.com/getkirby/cl
2626

2727
#### CLI Arguments
2828

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)
3030
- `--overwrite` - Overwrite existing alt texts (default: `false`)
3131
- `--dry-run` - Preview changes without updating files (default: `false`)
3232
- `--verbose` - Show detailed progress information (default: `false`)
@@ -57,15 +57,43 @@ kirby alter:generate --page "blog/my-article" --overwrite
5757
return [
5858
'medienbaecker.alter' => [
5959
'apiKey' => 'your-claude-api-key', // Set your Claude API key here
60+
'prompt' => 'Your custom prompt', // Optional: Custom prompt for alt text generation
6061
]
6162
];
6263

6364
```
6465

6566
Get your Claude API key from the [Anthropic Console](https://console.anthropic.com/).
6667

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) . '"';
92+
}
93+
```
94+
6795
## Installation
6896

6997
```
7098
composer require medienbaecker/kirby-alter
71-
```
99+
```

0 commit comments

Comments
 (0)