Skip to content

Commit

Permalink
added previewUrl prop in storage options (#639)
Browse files Browse the repository at this point in the history
  • Loading branch information
nivlempert1 authored Jul 3, 2024
1 parent 75d6b4d commit 57b598c
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
3 changes: 2 additions & 1 deletion packages/firecms_core/src/preview/PropertyPreview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -86,10 +86,11 @@ export const PropertyPreview = React.memo(function PropertyPreview<T extends CMS
url={value}
previewType={stringProperty.url}/>;
} else if (stringProperty.storage) {
const filePath = stringProperty.storage.previewUrl ? stringProperty.storage.previewUrl(value) : value;
content = <StorageThumbnail
storeUrl={property.storage?.storeUrl ?? false}
size={props.size}
storagePathOrDownloadUrl={value}/>;
storagePathOrDownloadUrl={filePath}/>;
} else if (stringProperty.markdown) {
content = <Markdown source={value} size={"small"}/>;
} else {
Expand Down
5 changes: 5 additions & 0 deletions packages/firecms_core/src/types/properties.ts
Original file line number Diff line number Diff line change
Expand Up @@ -783,6 +783,11 @@ export type StorageConfig = {
*/
postProcess?: (pathOrUrl: string) => Promise<string>;

/**
* You can use this prop in order to provide a custom preview URL.
* Useful when the file's path is different from the original field value
*/
previewUrl?: (fileName: string) => string;
}

/**
Expand Down

0 comments on commit 57b598c

Please sign in to comment.