Provider documentation
AWS Amplify
Generate requests for the Amplify Hosting image optimizer.
Setup
Install the framework package and the core package for the provider import:
npm install @desource/image @desource/image-svelte Save this as image.config.ts beside your example component. Replace sample domains and identifiers with
your own.
import type { ImageConfig } from '@desource/image';
import { awsAmplifyProvider } from '@desource/image/providers/awsAmplify';
export const imageConfig = {
provider: 'awsAmplify',
domains: ['images.example.com'],
screens: { card: 800, card2x: 1600 },
providers: {
awsAmplify: awsAmplifyProvider({
"path": "/_amplify/image",
"defaultQuality": 80
})
}
} satisfies ImageConfig; Registering this provider makes it the default for the configured components. To mix services, register each
provider and set provider="awsAmplify" on the image that should use this one.
Image source
Use a hosted local file or an absolute source URL allowed by your image configuration and Amplify deployment.
/img/hero.jpgUsage
The example uses the shared configuration above and the Svelte image component.
<script lang="ts">
import { Image, setImageConfig } from '@desource/image-svelte';
import { imageConfig } from './image.config';
setImageConfig(imageConfig);
</script>
<Image
src="/img/hero.jpg"
alt="Sample image" width={800} height={500}
modifiers={{
"quality": 80
}}
/>Provider options
Pass shared defaults such as screens, domains, aliases and presets to the image configuration. Pass provider-specific defaults as modifiers in the provider factory.
Modifiers
Maps width, height, quality, format and fit to the Amplify request. Width is rounded up to a configured screen width, or capped at the largest.
Set dimensions on the component and pass service-specific operations through modifiers, as shown
above. See the provider source for exact mappings and the service documentation for accepted values.
Provider notes
- Auto-detected on Amplify. Your framework deployment must expose /_amplify/image and configure imageSettings in its deployment manifest.
- Keep image.screens and generated density widths aligned with deployed imageSettings.sizes. Remote domains and formats must also be permitted by the deployment.
- Cache and allowed-format settings are deployment configuration; this provider generates request URLs.