{
const mediaFolders = selectMediaFolders(configState.config, collection, entry);
if (mediaFolders.length > 0) {
const files = await Promise.all(
- mediaFolders.map(folder => this.implementation.getMedia(folder)),
+ mediaFolders.map(folder => {
+ const mediaPath = selectMediaFilePublicPath(
+ configState.config!,
+ collection,
+ '',
+ entry,
+ undefined,
+ );
+ return this.implementation.getMedia(folder, mediaPath);
+ }),
);
entry.mediaFiles = entry.mediaFiles.concat(...files);
} else {
diff --git a/packages/core/src/backends/proxy/implementation.ts b/packages/core/src/backends/proxy/implementation.ts
index 6aafe7bf..63e93323 100644
--- a/packages/core/src/backends/proxy/implementation.ts
+++ b/packages/core/src/backends/proxy/implementation.ts
@@ -48,6 +48,7 @@ function deserializeMediaFile({ id, content, encoding, path, name }: MediaFile)
export default class ProxyBackend implements BackendClass {
proxyUrl: string;
mediaFolder?: string;
+ publicFolder?: string;
options: {};
branch: string;
@@ -59,6 +60,7 @@ export default class ProxyBackend implements BackendClass {
this.branch = config.backend.branch || 'main';
this.proxyUrl = config.backend.proxy_url;
this.mediaFolder = config.media_folder;
+ this.publicFolder = config.public_folder;
this.options = options;
}
@@ -144,17 +146,17 @@ export default class ProxyBackend implements BackendClass {
});
}
- async getMedia(mediaFolder = this.mediaFolder) {
+ async getMedia(mediaFolder = this.mediaFolder, publicFolder = this.publicFolder) {
const files: { path: string; url: string }[] = await this.request({
action: 'getMedia',
- params: { branch: this.branch, mediaFolder },
+ params: { branch: this.branch, mediaFolder, publicFolder },
});
return files.map(({ url, path }) => {
const id = url;
const name = basename(path);
- return { id, name, displayURL: { id, path }, path };
+ return { id, name, displayURL: { id, path: url }, path };
});
}
diff --git a/packages/core/src/components/MediaLibrary/MediaLibraryCardGrid.tsx b/packages/core/src/components/MediaLibrary/MediaLibraryCardGrid.tsx
index 20225047..99aa0b9d 100644
--- a/packages/core/src/components/MediaLibrary/MediaLibraryCardGrid.tsx
+++ b/packages/core/src/components/MediaLibrary/MediaLibraryCardGrid.tsx
@@ -73,8 +73,8 @@ const CardWrapper = ({
{
columnCount,
} as CardGridItemData
}
+ style={{ overflow: 'hidden', overflowY: 'scroll' }}
>
{CardWrapper}
diff --git a/packages/core/src/components/MediaLibrary/MediaLibraryModal.tsx b/packages/core/src/components/MediaLibrary/MediaLibraryModal.tsx
index 218cbe1c..12f9645b 100644
--- a/packages/core/src/components/MediaLibrary/MediaLibraryModal.tsx
+++ b/packages/core/src/components/MediaLibrary/MediaLibraryModal.tsx
@@ -25,7 +25,7 @@ const StyledFab = styled(Fab)`
* TODO Responsive styling needs to be overhauled. Current setup requires specifying
* widths per breakpoint.
*/
-const cardWidth = `280px`;
+const cardWidth = `278px`;
const cardHeight = `240px`;
const cardMargin = `10px`;
diff --git a/packages/core/src/formats/JsonFormatter.ts b/packages/core/src/formats/JsonFormatter.ts
index 0dbf61d9..c235aa34 100644
--- a/packages/core/src/formats/JsonFormatter.ts
+++ b/packages/core/src/formats/JsonFormatter.ts
@@ -1,7 +1,12 @@
+import { isEmpty } from '../lib/util/string.util';
import FileFormatter from './FileFormatter';
class JsonFormatter extends FileFormatter {
fromFile(content: string) {
+ if (isEmpty(content)) {
+ return {};
+ }
+
return JSON.parse(content);
}
diff --git a/packages/core/src/interface.ts b/packages/core/src/interface.ts
index b3730107..53c318b8 100644
--- a/packages/core/src/interface.ts
+++ b/packages/core/src/interface.ts
@@ -436,7 +436,7 @@ export abstract class BackendClass {
abstract entriesByFiles(files: ImplementationFile[]): Promise;
abstract getMediaDisplayURL(displayURL: DisplayURL): Promise;
- abstract getMedia(folder?: string): Promise;
+ abstract getMedia(folder?: string, mediaPath?: string): Promise;
abstract getMediaFile(path: string): Promise;
abstract persistEntry(entry: BackendEntry, opts: PersistOptions): Promise;
diff --git a/packages/core/src/lib/util/collection.util.ts b/packages/core/src/lib/util/collection.util.ts
index ed22cb5c..81e9fad1 100644
--- a/packages/core/src/lib/util/collection.util.ts
+++ b/packages/core/src/lib/util/collection.util.ts
@@ -255,7 +255,7 @@ export function selectMediaFolders(config: Config, collection: Collection, entry
folders.unshift(selectMediaFolder(config, newCollection, entry, undefined));
}
- return [...new Set(...folders)];
+ return [...new Set(folders)];
}
export function getFieldsNames(fields: Field[] | undefined, prefix = '') {
let names = fields?.map(f => `${prefix}${f.name}`) ?? [];