traxxx-web/utils/media-path.js

57 lines
933 B
JavaScript
Raw Normal View History

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) {
if (!media) {
return null;
}
const path = getBasePath(media, type, options);
const filename = getFilename(media, type, options);
return `${path}/${filename}`;
}