feat: add support for custom image size file names (#7634)

Add support for custom file names in images sizes

```ts
{
  name: 'thumbnail',
  width: 400,
  height: 300,
  generateImageName: ({ height, sizeName, extension, width }) => {
    return `custom-${sizeName}-${height}-${width}.${extension}`
  },
}
```
This commit is contained in:
Paul
2024-08-12 12:25:20 -06:00
committed by GitHub
parent 78dd6a2d5b
commit 56aded8507
8 changed files with 128 additions and 9 deletions

View File

@@ -27,6 +27,7 @@ export interface Config {
enlarge: Enlarge;
reduce: Reduce;
'media-trim': MediaTrim;
'custom-file-name-media': CustomFileNameMedia;
'unstored-media': UnstoredMedia;
'externally-served-media': ExternallyServedMedia;
'uploads-1': Uploads1;
@@ -56,6 +57,7 @@ export interface Config {
export interface UserAuthOperations {
forgotPassword: {
email: string;
password: string;
};
login: {
email: string;
@@ -67,6 +69,7 @@ export interface UserAuthOperations {
};
unlock: {
email: string;
password: string;
};
}
/**
@@ -754,6 +757,34 @@ export interface MediaTrim {
};
};
}
/**
* This interface was referenced by `Config`'s JSON-Schema
* via the `definition` "custom-file-name-media".
*/
export interface CustomFileNameMedia {
id: string;
updatedAt: string;
createdAt: string;
url?: string | null;
thumbnailURL?: string | null;
filename?: string | null;
mimeType?: string | null;
filesize?: number | null;
width?: number | null;
height?: number | null;
focalX?: number | null;
focalY?: number | null;
sizes?: {
custom?: {
url?: string | null;
width?: number | null;
height?: number | null;
mimeType?: string | null;
filesize?: number | null;
filename?: string | null;
};
};
}
/**
* This interface was referenced by `Config`'s JSON-Schema
* via the `definition` "unstored-media".