Provider documentation
GitHub Avatars
Request a GitHub avatar at a bounded square size.
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 { githubProvider } from '@desource/image/providers/github';
export const imageConfig = {
provider: 'github',
providers: {
github: githubProvider({
"baseURL": "https://avatars.githubusercontent.com/"
})
}
} satisfies ImageConfig; Registering this provider makes it the default for the configured components. To mix services, register each
provider and set provider="github" on the image that should use this one.
Image source
Use a GitHub avatar path such as /u/{numeric-user-id}.
/u/1Usage
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="/u/1"
alt="Sample image" width={128} height={128}
/>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
The greater of width and height selects s, clamped to 1–460. The default is 460. The adapter also sets v=4.
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
- Quality, format, fit and other general image modifiers do not affect the generated URL.
- This provider serves avatars; it does not optimize arbitrary repository images.