Prismic

Provider documentation

Prismic

Transform Prismic image fields while preserving editor-provided query parameters.

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 { prismicProvider } from '@desource/image/providers/prismic';

export const imageConfig = {
  provider: 'prismic',
  providers: {
    prismic: prismicProvider({
      "baseURL": "https://images.prismic.io"
    })
  }
} satisfies ImageConfig;

Registering this provider makes it the default for the configured components. To mix services, register each provider and set provider="prismic" on the image that should use this one.

Image source

Use the image URL returned by Prismic, including crop and other editor-generated parameters.

https://images.prismic.io/your-repository/photo.jpg

Usage

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="https://images.prismic.io/your-repository/photo.jpg"
  alt="Sample image" width={800} height={500}
  modifiers={{
  "quality": 80,
  "format": "webp",
  "fit": "cover"
}}
/>

Provider options

baseURL
Default Prismic image delivery root.

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

Uses Imgix-style width, height, quality, format, crop and fit modifiers.

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

  • Existing query parameters are preserved unless overridden by a requested modifier.
  • Sources starting with the Unsplash CDN hostname are delegated to the Unsplash provider.
← Back to all providers