traxxx-web/utils/media-path.js

60 lines
994 B
JavaScript

const config = {
client: {
media: {
assetPath: '/img',
mediaPath: '/media',
s3Path: 'https://cdndev.traxxx.me',
},
},
};
function getBasePath(media, type, options) {
/*
if (store.state.ui.sfw) {
return config.client.media.assetPath;
}
*/
if (media.isS3) {
return config.client.media.s3Path;
}
if (options?.local) {
return config.client.media.assetPath;
}
return config.client.media.mediaPath;
}
function getFilename(media, type, options) {
/*
if (store.state.ui.sfw && type && !options?.original) {
return media.sfw[type];
}
if (store.state.ui.sfw) {
return media.sfw.path;
}
*/
if (type && !options?.original) {
return media[type];
}
return media.path;
}
export function getMediaPath(media, type, options) {
console.log('media', media);
if (!media) {
return null;
}
const path = getBasePath(media, type, options);
const filename = getFilename(media, type, options);
console.log(path, filename);
return `${path}/${filename}`;
}