summaryrefslogtreecommitdiff
path: root/packages/integrations/image/src/utils.ts
diff options
context:
space:
mode:
Diffstat (limited to 'packages/integrations/image/src/utils.ts')
-rw-r--r--packages/integrations/image/src/utils.ts6
1 files changed, 6 insertions, 0 deletions
diff --git a/packages/integrations/image/src/utils.ts b/packages/integrations/image/src/utils.ts
index 44c338cf4..80dff1b6e 100644
--- a/packages/integrations/image/src/utils.ts
+++ b/packages/integrations/image/src/utils.ts
@@ -1,5 +1,6 @@
import fs from 'fs';
import path from 'path';
+import { shorthash } from './shorthash.js';
import type { OutputFormat, TransformOptions } from './types';
export function isOutputFormat(value: string): value is OutputFormat {
@@ -48,6 +49,11 @@ export function propsToFilename({ src, width, height, format }: TransformOptions
const ext = path.extname(src);
let filename = src.replace(ext, '');
+ // for remote images, add a hash of the full URL to dedupe images with the same filename
+ if (isRemoteImage(src)) {
+ filename += `-${shorthash(src)}`;
+ }
+
if (width && height) {
return `${filename}_${width}x${height}.${format}`;
} else if (width) {