This Astro component imports the Image from astro:assets and displays an optimized image with a blurred placeholder. The image will load faster and look good on all devices.
B. A broken image link because the path is incorrect
C. An optimized image of width 400 pixels with alt text 'A mountain'
D. An image with original size ignoring width attribute
Solution
Step 1: Understand Image behavior with src and width
The Image component optimizes the image and respects the width prop to resize it.
Step 2: Check alt text and path usage
The alt text is provided correctly, and the relative path is valid for Astro assets.
Final Answer:
An optimized image of width 400 pixels with alt text 'A mountain' -> Option C
Quick Check:
Image optimization with width and alt = D [OK]
Hint: Width prop resizes image; alt improves accessibility [OK]
Common Mistakes:
Assuming width is ignored
Thinking relative paths break images
Confusing alt text with title
4. Identify the error in this Astro code using Image from astro:assets:
---
import { Image } from 'astro:assets';
const logo = '/images/logo.png';
---
medium
A. The src path should be relative, not absolute
B. Missing width or height props causes a runtime error
C. The alt attribute is required but missing
D. The import statement is incorrect
Solution
Step 1: Check the src path format
The Image component expects a relative path or imported asset, not an absolute URL path starting with '/'.
Step 2: Verify other props and import
The alt attribute is present, and the import is correct; width/height are optional but recommended.
Final Answer:
The src path should be relative, not absolute -> Option A
Quick Check:
Use relative paths for src = B [OK]
Hint: Use relative paths for images, not absolute URLs [OK]
Common Mistakes:
Using absolute paths starting with '/'
Assuming width is mandatory
Confusing import syntax
5. You want to serve an image with a blurred placeholder while it loads using astro:assets. Which of the following code snippets correctly implements this feature?