@prezly/theme-kit-core
Version:
Data layer and utility library for developing Prezly themes with JavaScript
38 lines (36 loc) • 1.19 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.getArchiveDownloadUrl = getArchiveDownloadUrl;
exports.getCoverImage = getCoverImage;
exports.isEmpty = isEmpty;
var _constants = require("./constants.cjs");
function isEmpty(gallery) {
return gallery.images_number === 0 && gallery.videos_number === 0;
}
function getCoverImage(gallery) {
var {
thumbnail_image,
images
} = gallery;
if (thumbnail_image) {
return JSON.parse(thumbnail_image);
}
if (images.length) {
return images[0].uploadcare_image;
}
return null;
}
/**
* This method constructs a URL to download all images in the Gallery as a single archive.
*
* @param uuid Uploadcare files group UUID
* @param title Filename for the saved archive. Usually it is the Gallery title.
* @returns URL to an archive containing all of the images in the Gallery.
*/
function getArchiveDownloadUrl(uuid, title) {
// Uploadcare doesn't like slashes in filenames even in encoded form.
var filename = encodeURIComponent(title.replace(/\//g, '_'));
return "".concat(_constants.ASSETS_SECONDARY_CDN_URL, "/").concat(uuid, "/archive/zip/").concat(filename, ".zip");
}