getTargetDimensions() — astro Function Reference
Architecture documentation for the getTargetDimensions() function in service.ts from the astro codebase.
Entity Profile
Dependency Diagram
graph TD 0f9d5a56_bd2b_84fb_9878_5bcb5fd97446["getTargetDimensions()"] f0f55fc4_9c63_b35c_86d8_8eb3e4fa20ee["service.ts"] 0f9d5a56_bd2b_84fb_9878_5bcb5fd97446 -->|defined in| f0f55fc4_9c63_b35c_86d8_8eb3e4fa20ee 1cf9a504_a136_9deb_7e14_254892825464["baseService.getHTMLAttributes()"] 1cf9a504_a136_9deb_7e14_254892825464 -->|calls| 0f9d5a56_bd2b_84fb_9878_5bcb5fd97446 44ac12c6_fabb_dea8_00ac_961e59eb3b88["baseService.getSrcSet()"] 44ac12c6_fabb_dea8_00ac_961e59eb3b88 -->|calls| 0f9d5a56_bd2b_84fb_9878_5bcb5fd97446 style 0f9d5a56_bd2b_84fb_9878_5bcb5fd97446 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
packages/astro/src/assets/services/service.ts lines 432–455
function getTargetDimensions(options: ImageTransform) {
let targetWidth = options.width;
let targetHeight = options.height;
if (isESMImportedImage(options.src)) {
const aspectRatio = options.src.width / options.src.height;
if (targetHeight && !targetWidth) {
// If we have a height but no width, use height to calculate the width
targetWidth = Math.round(targetHeight * aspectRatio);
} else if (targetWidth && !targetHeight) {
// If we have a width but no height, use width to calculate the height
targetHeight = Math.round(targetWidth / aspectRatio);
} else if (!targetWidth && !targetHeight) {
// If we have neither width or height, use the original image's dimensions
targetWidth = options.src.width;
targetHeight = options.src.height;
}
}
// TypeScript doesn't know this, but because of previous hooks we always know that targetWidth and targetHeight are defined
return {
targetWidth: targetWidth!,
targetHeight: targetHeight!,
};
}
Domain
Subdomains
Source
Frequently Asked Questions
What does getTargetDimensions() do?
getTargetDimensions() is a function in the astro codebase, defined in packages/astro/src/assets/services/service.ts.
Where is getTargetDimensions() defined?
getTargetDimensions() is defined in packages/astro/src/assets/services/service.ts at line 432.
What calls getTargetDimensions()?
getTargetDimensions() is called by 2 function(s): baseService.getHTMLAttributes, baseService.getSrcSet.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free