payload-plugin-cloud-storage
Version:
Remote storage plugin for Payload CMS.
25 lines (24 loc) • 1.13 kB
JavaScript
;
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const isImage_1 = __importDefault(require("../validation/isImage"));
const initAdminThumbnail = (endpointPropertyName, existingValue) => {
return (args) => {
var _a, _b;
if ((args === null || args === void 0 ? void 0 : args.doc) && (0, isImage_1.default)((_a = args.doc) === null || _a === void 0 ? void 0 : _a.mimeType)) {
const { doc } = args;
const sizes = doc === null || doc === void 0 ? void 0 : doc.sizes;
if (typeof existingValue === 'string') {
const targetSize = (_b = sizes === null || sizes === void 0 ? void 0 : sizes[existingValue]) === null || _b === void 0 ? void 0 : _b[endpointPropertyName];
if (targetSize) {
return targetSize;
}
}
return doc[endpointPropertyName];
}
return '';
};
};
exports.default = initAdminThumbnail;