mirror of
https://github.com/withastro/astro.git
synced 2024-12-30 22:03:56 -05:00
fix: improve error for inferSize and Image component (#11823)
* fix: improve error for inferSize and Image component * add changeset * move isRemovePath check --------- Co-authored-by: Erika <3019731+Princesseuh@users.noreply.github.com>
This commit is contained in:
parent
5a4edebfd2
commit
a3d30a602a
2 changed files with 11 additions and 1 deletions
5
.changeset/lazy-flowers-destroy.md
Normal file
5
.changeset/lazy-flowers-destroy.md
Normal file
|
@ -0,0 +1,5 @@
|
|||
---
|
||||
'astro': patch
|
||||
---
|
||||
|
||||
fix: improve error message when inferSize is used in local images with the Image component
|
|
@ -1,3 +1,4 @@
|
|||
import { isRemotePath } from '@astrojs/internal-helpers/path';
|
||||
import type { AstroConfig } from '../@types/astro.js';
|
||||
import { AstroError, AstroErrorData } from '../core/errors/index.js';
|
||||
import { DEFAULT_HASH_PROPS } from './consts.js';
|
||||
|
@ -65,7 +66,11 @@ export async function getImage(
|
|||
};
|
||||
|
||||
// Infer size for remote images if inferSize is true
|
||||
if (options.inferSize && isRemoteImage(resolvedOptions.src)) {
|
||||
if (
|
||||
options.inferSize &&
|
||||
isRemoteImage(resolvedOptions.src) &&
|
||||
isRemotePath(resolvedOptions.src)
|
||||
) {
|
||||
const result = await inferRemoteSize(resolvedOptions.src); // Directly probe the image URL
|
||||
resolvedOptions.width ??= result.width;
|
||||
resolvedOptions.height ??= result.height;
|
||||
|
|
Loading…
Reference in a new issue