Image support!
Some checks failed
Test / test (push) Failing after 5s
Build and Deploy Nuxt / build (push) Successful in 1m46s

This commit is contained in:
2026-11-20 19:10:28 +01:00
parent d61659cfdd
commit fe662bb351
11 changed files with 119 additions and 21 deletions

View File

@@ -23,6 +23,8 @@ const loading = ref(true);
const campaignId = computed(() => Campaign.value?._id ?? Campaign.value?.id ?? null);
const isActor = computed(() => target.value?.type === 'actor');
const isItem = computed(() => target.value?.type === 'item');
const isMedia = computed(() => target.value?.type === 'media');
const isImage = computed(() => String(entry.value?.mimeType ?? '').startsWith('image/'));
onMounted(async () => {
const targets = await LoadLinkTargets(campaignId.value);
@@ -71,6 +73,7 @@ function resolveImage(image) {
}
const imageUrl = computed(() => resolveImage(entry.value?.image));
const mediaUrl = computed(() => entry.value?.file ? `${getBaseUrl()}/public/${entry.value.file}` : '');
const initial = computed(() => String(entry.value?.name ?? '?').slice(0, 1).toUpperCase());
// --- The item's sheet, in the small ---
@@ -137,6 +140,11 @@ async function openSheet() {
</span>
</span>
<span v-else-if="entry && isMedia" class="embedded-media">
<img v-if="isImage" class="embed-image" :src="mediaUrl" :alt="entry.name">
<a v-else class="embed-file" :href="mediaUrl" target="_blank" rel="noopener">{{ entry.name }}</a>
</span>
<span v-else class="embedded-entry embedded-missing" :title="translate('campaigns.link-preview.not-found')">{{ href }}</span>
</template>
@@ -226,6 +234,19 @@ async function openSheet() {
.embed-open:hover { background: var(--color-button-hover); }
/* An embedded upload: an image fills the note's width, any other file is offered as a link. */
.embedded-media { display: inline-block; max-width: 100%; margin: 8px 0; vertical-align: top; }
.embed-image {
display: block;
max-width: 100%;
height: auto;
border: 1px solid var(--color-border);
border-radius: 8px;
}
.embed-file { color: var(--color-link); word-break: break-word; }
.embed-vitals { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; }
.embed-stat {

View File

@@ -126,7 +126,7 @@ function linkEntry(target) {
kind: 'link',
value: target,
label: `[[${target.label}]]`,
hint: t(`campaigns.sections.${target.type}s`)
hint: t(target.type === 'media' ? 'campaigns.sections.media' : `campaigns.sections.${target.type}s`)
};
}
@@ -451,6 +451,12 @@ async function openLinkTarget(target) {
if (target.type === 'map') {
const map = await LoadLinkEntry(campaignId.value, 'map', target.id);
if (map) AnchorMap(map);
return;
}
if (target.type === 'media') {
const media = await LoadLinkEntry(campaignId.value, 'media', target.id);
if (media) CreateWindow('media_viewer', { media });
}
}