Fixed SFW determination in image path function.

This commit is contained in:
DebaucheryLibrarian 2021-03-07 20:00:57 +01:00
parent 44523609c1
commit f91437e03c
2 changed files with 35 additions and 6 deletions

View File

@ -47,6 +47,7 @@
>
<Logo
v-if="!sfw"
:photo="tag.poster"
favicon
/>

View File

@ -24,13 +24,41 @@ async function init() {
const app = createApp(Container);
const events = mitt();
function getPath(media, type, options) {
const path = (store.state.ui.sfw && media.assetPath)
|| (media.isS3 && config.media.s3Path)
|| (options?.local && config.media.assetPath)
|| config.media.mediaPath;
function getBasePath(media, type, options) {
if (store.state.ui.sfw) {
return config.media.assetPath;
}
const filename = type && !options?.original ? media[type] : media.path;
if (media.isS3) {
return config.media.s3Path;
}
if (options?.local) {
return config.media.assetPath;
}
return config.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;
}
function getPath(media, type, options) {
const path = getBasePath(media, type, options);
const filename = getFilename(media, type, options);
return `${path}/${filename}`;
}