TwicPics

Provider documentation

TwicPics

Build ordered TwicPics transformation expressions.

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

export const imageConfig = {
  provider: 'twicpics',
  providers: {
    twicpics: twicpicsProvider({
      "baseURL": "https://your-domain.twic.pics"
    })
  }
} satisfies ImageConfig;

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

Image source

Use a path under the configured TwicPics source.

/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="/photo.jpg"
  alt="Sample image" width={800} height={500}
  modifiers={{
  "quality": 80,
  "focus": "auto"
}}
/>

Provider options

baseURL
TwicPics domain with a source path configured in its dashboard.

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

Width, height and fit generate a resizing operation. Supports quality, format, focus, crop, cover, contain, resize, flip, turn, zoom, background and truecolor.

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

  • Transformations are ordered. Place focus before crop or cover when the crop should use that focus point.
  • Use a single dimension to preserve the source ratio. Outside uses a contain box based on the larger requested dimension.
  • Use provider modifiers for TwicPics expressions such as focus: auto, cover: 16:9, turn: left or zoom: 1.5.
← Back to all providers