@@ -122,14 +122,34 @@ Returns an object with reusable export methods:
122122
123123All capture methods accept an ` options` object:
124124
125- | Option | Type | Default | Description |
126- | ----------------- | ------- | -------- | ------------------------------------------ |
127- | ` compress` | boolean | ` true ` | Removes redundant styles |
128- | ` fast` | boolean | ` true ` | Skips idle delay for faster results |
129- | ` embedFonts` | boolean | ` false ` | Inlines fonts (icon fonts always embedded) |
130- | ` scale` | number | ` 1 ` | Output scale multiplier |
131- | ` backgroundColor` | string | ` " #fff" ` | Fallback color for JPG/WebP |
132- | ` quality` | number | ` 1 ` | Quality for JPG/WebP (0 to 1) |
125+ | Option | Type | Default | Description |
126+ | ----------------- | -------- | -------- | ------------------------------------------ |
127+ | ` compress` | boolean | ` true ` | Removes redundant styles |
128+ | ` fast` | boolean | ` true ` | Skips idle delay for faster results |
129+ | ` embedFonts` | boolean | ` false ` | Inlines fonts (icon fonts always embedded) |
130+ | ` scale` | number | ` 1 ` | Output scale multiplier |
131+ | ` backgroundColor` | string | ` " #fff" ` | Fallback color for JPG/WebP |
132+ | ` quality` | number | ` 1 ` | Quality for JPG/WebP (0 to 1) |
133+ | ` crossOrigin` | function | - | Function to determine CORS mode per image URL |
134+
135+ ### Cross-Origin Images
136+
137+ By default, snapDOM loads images with ` crossOrigin= " anonymous" ` . You can customize this behavior using the ` crossOrigin` option:
138+
139+ ` ` ` js
140+ const result = await snapdom (element, {
141+ crossOrigin : (url ) => {
142+ // Use credentials for same-origin images
143+ if (url .startsWith (window .location .origin )) {
144+ return " use-credentials" ;
145+ }
146+ // Use anonymous for cross-origin images
147+ return " anonymous" ;
148+ }
149+ });
150+ ` ` `
151+
152+ This is useful when your images require authentication or when dealing with credentialed requests.
133153
134154### Download options
135155
@@ -164,6 +184,7 @@ import { snapdom, preCache } from './snapdom.mjs';
164184
165185* ` embedFonts` *(boolean, default: true)* — Inlines non-icon fonts during preload.
166186* ` reset` *(boolean, default: false)* — Clears all existing internal caches.
187+ * ` crossOrigin` *(function)* — Function to determine CORS mode per image URL during preload.
167188
168189
169190## Features
@@ -177,7 +198,7 @@ import { snapdom, preCache } from './snapdom.mjs';
177198
178199## Limitations
179200
180- * External images must be CORS-accessible
201+ * External images must be CORS-accessible (use ` crossOrigin ` option for credentialed requests)
181202* Iframes are not supported
182203* When WebP format is used on Safari, it will fallback to PNG rendering.
183204
0 commit comments