full site update
This commit is contained in:
19
node_modules/astro/components/Image.astro
generated
vendored
19
node_modules/astro/components/Image.astro
generated
vendored
@@ -1,5 +1,6 @@
|
||||
---
|
||||
import { type LocalImageProps, type RemoteImageProps, getImage } from 'astro:assets';
|
||||
import { getImage, imageConfig, type LocalImageProps, type RemoteImageProps } from 'astro:assets';
|
||||
import type { UnresolvedImageTransform } from '../dist/assets/types';
|
||||
import { AstroError, AstroErrorData } from '../dist/core/errors/index.js';
|
||||
import type { HTMLAttributes } from '../types';
|
||||
|
||||
@@ -23,7 +24,16 @@ if (typeof props.height === 'string') {
|
||||
props.height = parseInt(props.height);
|
||||
}
|
||||
|
||||
const image = await getImage(props);
|
||||
const layout = props.layout ?? imageConfig.layout ?? 'none';
|
||||
|
||||
if (layout !== 'none') {
|
||||
// Apply defaults from imageConfig if not provided
|
||||
props.layout ??= imageConfig.layout;
|
||||
props.fit ??= imageConfig.objectFit ?? 'cover';
|
||||
props.position ??= imageConfig.objectPosition ?? 'center';
|
||||
}
|
||||
|
||||
const image = await getImage(props as UnresolvedImageTransform);
|
||||
|
||||
const additionalAttributes: HTMLAttributes<'img'> = {};
|
||||
if (image.srcSet.values.length > 0) {
|
||||
@@ -33,6 +43,9 @@ if (image.srcSet.values.length > 0) {
|
||||
if (import.meta.env.DEV) {
|
||||
additionalAttributes['data-image-component'] = 'true';
|
||||
}
|
||||
|
||||
const { class: className, ...attributes } = { ...additionalAttributes, ...image.attributes };
|
||||
---
|
||||
|
||||
<img src={image.src} {...additionalAttributes} {...image.attributes} />
|
||||
{/* Applying class outside of the spread prevents it from applying unnecessary astro-* classes */}
|
||||
<img src={image.src} {...attributes} class={className} />
|
||||
|
Reference in New Issue
Block a user