Charaktere: Geschlecht (Default maennlich) plus weibliche Platzhalterportraets
Spalte characters.gender mit Migration, Auswahl im Formular, Anzeige auf Bogen und im PDF-Export. 12 neue Platzhalterbilder assets/portraits/<klasse>-weiblich.webp (fal.ai nano-banana-pro/edit) werden von portrait_placeholder_rel() nach Geschlecht gewaehlt.
This commit is contained in:
parent
0cbaeeafcd
commit
9388d04e98
23 changed files with 62 additions and 13 deletions
|
|
@ -28,11 +28,22 @@ function portrait_dir(): string
|
|||
return WS_ROOT . '/' . WS_PORTRAIT_REL_DIR;
|
||||
}
|
||||
|
||||
function portrait_placeholder_rel(string $className): string
|
||||
function portrait_placeholder_rel(string $className, string $gender = WS_DEFAULT_GENDER): string
|
||||
{
|
||||
$slug = portrait_class_slug($className);
|
||||
$rel = 'assets/portraits/' . $slug . '.webp';
|
||||
return is_file(WS_ROOT . '/' . $rel) ? $rel : '';
|
||||
// Weibliche Charaktere bekommen …-weiblich.webp; fehlt die Variante,
|
||||
// greift weiterhin das neutrale Platzhalterbild der Klasse.
|
||||
$candidates = [];
|
||||
if (character_gender($gender) === 'weiblich') {
|
||||
$candidates[] = 'assets/portraits/' . $slug . '-weiblich.webp';
|
||||
}
|
||||
$candidates[] = 'assets/portraits/' . $slug . '.webp';
|
||||
foreach ($candidates as $rel) {
|
||||
if (is_file(WS_ROOT . '/' . $rel)) {
|
||||
return $rel;
|
||||
}
|
||||
}
|
||||
return '';
|
||||
}
|
||||
|
||||
/** Anzeige-URL: eigenes Bild, sonst Platzhalter der Klasse, sonst leer. */
|
||||
|
|
@ -42,7 +53,7 @@ function portrait_url(array $character): string
|
|||
if ($stored !== '' && is_file(WS_ROOT . '/' . ltrim($stored, '/'))) {
|
||||
return url('/' . ltrim($stored, '/'));
|
||||
}
|
||||
$placeholder = portrait_placeholder_rel((string) ($character['class_name'] ?? ''));
|
||||
$placeholder = portrait_placeholder_rel((string) ($character['class_name'] ?? ''), (string) ($character['gender'] ?? ''));
|
||||
return $placeholder === '' ? '' : url('/' . $placeholder);
|
||||
}
|
||||
|
||||
|
|
@ -161,7 +172,7 @@ function portrait_jpeg_bytes(array $character): string
|
|||
}
|
||||
}
|
||||
|
||||
$placeholder = portrait_placeholder_rel((string) ($character['class_name'] ?? ''));
|
||||
$placeholder = portrait_placeholder_rel((string) ($character['class_name'] ?? ''), (string) ($character['gender'] ?? ''));
|
||||
if ($placeholder === '' || !function_exists('imagecreatefromwebp')) {
|
||||
return '';
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue