feat(media): support external https image urls for entities

Allow entities to use full https:// URLs as their image path
Validate external URLs to prevent http://, data:, or credentials
Update API responses and frontend components to handle external sources
This commit is contained in:
2026-05-11 23:21:34 +08:00
parent 929c148c56
commit 8caa95e78e
6 changed files with 74 additions and 8 deletions

View File

@@ -586,12 +586,17 @@ function pokemonImageLabel(image: PokemonImage) {
if (image.source === 'upload') {
return t('media.uploadedImage');
}
if (image.source === 'external') {
return t('media.image');
}
return `${image.version} - ${image.variant}`;
}
function pokemonImageAlt(image: PokemonImage) {
const name = pokemonForm.value.name.trim() || (pokemonForm.value.id.trim() ? `#${pokemonForm.value.id.trim()}` : t('pages.pokemon.title'));
return image.source === 'upload' ? t('media.imageAlt', { name }) : t('pages.pokemon.imageAlt', { name, variant: image.variant });
return image.source === 'upload' || image.source === 'external'
? t('media.imageAlt', { name })
: t('pages.pokemon.imageAlt', { name, variant: image.variant });
}
function selectPokemonImage(image: PokemonImage) {