Some checks failed
Build & Deploy / 🔍 Prepare (push) Successful in 20s
Build & Deploy / 🧪 QA (push) Failing after 34s
Build & Deploy / 🏗️ Build (push) Has started running
Build & Deploy / 🚀 Deploy (push) Has been cancelled
Build & Deploy / 🧪 Smoke Test (push) Has been cancelled
Build & Deploy / ⚡ Lighthouse (push) Has been cancelled
Build & Deploy / 🔔 Notify (push) Has been cancelled
35 lines
1.3 KiB
Plaintext
35 lines
1.3 KiB
Plaintext
/**
|
|
* Mutates the incoming select object to append fields required for upload thumbnails
|
|
* @param collectionConfig
|
|
* @param select
|
|
*/ export const appendUploadSelectFields = ({ collectionConfig, select })=>{
|
|
if (!collectionConfig.upload || !select) {
|
|
return;
|
|
}
|
|
select.mimeType = true;
|
|
select.thumbnailURL = true;
|
|
if (collectionConfig.upload.imageSizes && collectionConfig.upload.imageSizes.length > 0) {
|
|
if (collectionConfig.upload.adminThumbnail && typeof collectionConfig.upload.adminThumbnail === 'string') {
|
|
/** Only return image size properties that are required to generate the adminThumbnailURL */ select.sizes = {
|
|
[collectionConfig.upload.adminThumbnail]: {
|
|
filename: true
|
|
}
|
|
};
|
|
} else {
|
|
/** Only return image size properties that are required for thumbnails */ select.sizes = collectionConfig.upload.imageSizes.reduce((acc, imageSizeConfig)=>{
|
|
return {
|
|
...acc,
|
|
[imageSizeConfig.name]: {
|
|
filename: true,
|
|
url: true,
|
|
width: true
|
|
}
|
|
};
|
|
}, {});
|
|
}
|
|
} else {
|
|
select.url = true;
|
|
}
|
|
};
|
|
|
|
//# sourceMappingURL=appendUploadSelectFields.js.map |