Home / File/ image-service.ts — astro Source File

image-service.ts — astro Source File

Architecture documentation for image-service.ts, a typescript file in the astro codebase. 5 imports, 0 dependents.

File typescript CoreAstro RoutingSystem 5 imports 1 functions

Entity Profile

Dependency Diagram

graph LR
  ef05f0b4_0d78_c126_2b89_f6c45f336291["image-service.ts"]
  e61ca6ff_5814_4ef5_6c0a_36558266a7da["../utils/assets.js"]
  ef05f0b4_0d78_c126_2b89_f6c45f336291 --> e61ca6ff_5814_4ef5_6c0a_36558266a7da
  e4df8f29_fb2f_3d70_a962_fdf6a3670b22["path"]
  ef05f0b4_0d78_c126_2b89_f6c45f336291 --> e4df8f29_fb2f_3d70_a962_fdf6a3670b22
  f16d8c76_2866_6150_bd14_0347b59abfe9["astro"]
  ef05f0b4_0d78_c126_2b89_f6c45f336291 --> f16d8c76_2866_6150_bd14_0347b59abfe9
  01c5fbc2_ddb6_180b_d98d_2ff488540314["assets"]
  ef05f0b4_0d78_c126_2b89_f6c45f336291 --> 01c5fbc2_ddb6_180b_d98d_2ff488540314
  f8ab2297_5406_4f9e_e15c_c4eb026871f9["utils"]
  ef05f0b4_0d78_c126_2b89_f6c45f336291 --> f8ab2297_5406_4f9e_e15c_c4eb026871f9
  style ef05f0b4_0d78_c126_2b89_f6c45f336291 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

/// <reference types="vite/client" />
import { joinPaths } from '@astrojs/internal-helpers/path';
import type { ExternalImageService } from 'astro';
import { baseService } from 'astro/assets';
import { isESMImportedImage } from 'astro/assets/utils';
import { isRemoteAllowed } from '../utils/assets.js';

const service: ExternalImageService = {
	...baseService,
	getURL: (options, imageConfig) => {
		const resizingParams = ['onerror=redirect'];
		if (options.width) resizingParams.push(`width=${options.width}`);
		if (options.height) resizingParams.push(`height=${options.height}`);
		if (options.quality) resizingParams.push(`quality=${options.quality}`);
		if (options.fit) resizingParams.push(`fit=${options.fit}`);
		if (options.format) resizingParams.push(`format=${options.format}`);

		let imageSource = '';
		if (isESMImportedImage(options.src)) {
			imageSource = options.src.src;
		} else if (isRemoteAllowed(options.src, imageConfig)) {
			imageSource = options.src;
		} else {
			// If it's not an imported image, nor is it allowed using the current domains or remote patterns, we'll just return the original URL
			return options.src;
		}

		const imageEndpoint = joinPaths(
			import.meta.env.BASE_URL,
			'/cdn-cgi/image',
			resizingParams.join(','),
			imageSource,
		);

		return imageEndpoint;
	},
};

export default service;

Domain

Subdomains

Functions

Dependencies

  • ../utils/assets.js
  • assets
  • astro
  • path
  • utils

Frequently Asked Questions

What does image-service.ts do?
image-service.ts is a source file in the astro codebase, written in typescript. It belongs to the CoreAstro domain, RoutingSystem subdomain.
What functions are defined in image-service.ts?
image-service.ts defines 1 function(s): service.getURL.
What does image-service.ts depend on?
image-service.ts imports 5 module(s): ../utils/assets.js, assets, astro, path, utils.
Where is image-service.ts in the architecture?
image-service.ts is located at packages/integrations/cloudflare/src/entrypoints/image-service.ts (domain: CoreAstro, subdomain: RoutingSystem, directory: packages/integrations/cloudflare/src/entrypoints).

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free