Skip to content

Commit 13397fa

Browse files
committed
fix #476
1 parent 615ad69 commit 13397fa

File tree

4 files changed

+21
-4
lines changed

4 files changed

+21
-4
lines changed

exampleVault/View Fields/View Field.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ images:
2121
otherImages:
2222
- "[[Other/Images/img_flower.webp]]"
2323
- "[image](Other/Images/img_flower.webp)"
24+
remoteImage: https://picsum.photos/200/300
2425
---
2526

2627
`INPUT[number:number1]`
@@ -60,20 +61,32 @@ Self Loop Error: `VIEW[**{computed}**][text():computed]`
6061
link with render markdown: `VIEW[\[\[{file}|link\]\]][text(renderMarkdown)]`
6162
link with link view field: `VIEW[{file}|this is a link][link]`
6263

64+
## Images
65+
66+
A single image works
67+
6368
```meta-bind
6469
INPUT[imageSuggester(optionQuery("Other/Images")):image]
6570
```
6671

6772
`VIEW[{image}][image]`
6873

74+
View fields can also display a list of images.
75+
6976
```meta-bind
7077
INPUT[imageListSuggester(optionQuery("Other/Images")):images]
7178
```
7279

7380
`VIEW[{images}][image]`
7481

82+
Both markdown link types are supported.
83+
7584
`VIEW[{otherImages}][image]`
7685

86+
External images work as well.
87+
88+
`VIEW[{remoteImage}][image]`
89+
7790
## Arrays and Objects
7891

7992
Plain Text:

packages/core/src/fields/viewFields/fields/ImageVF.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ export class ImageVF extends AbstractViewField<string> {
8888
this.component = mount(ImageGrid, {
8989
target: container,
9090
props: {
91-
images: linkList.map(x => x.target),
91+
images: linkList.map(x => ({ link: x.target, internal: x.internal })),
9292
plugin: this.mountable.plugin,
9393
},
9494
});

packages/core/src/utils/components/ImageCard.svelte

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,16 @@
44
const {
55
plugin,
66
image,
7+
internal = true,
78
}: {
89
plugin: IPlugin;
910
image: string;
11+
internal?: boolean;
1012
} = $props();
13+
14+
let imageUri = $derived(internal ? plugin.internal.imagePathToUri(image) : image);
1115
</script>
1216

1317
<div class="mb-image-card">
14-
<img class="mb-image-card-image" src={plugin.internal.imagePathToUri(image)} alt={image} />
18+
<img class="mb-image-card-image" src={imageUri} alt={image} />
1519
</div>

packages/core/src/utils/components/ImageGrid.svelte

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,12 @@
77
images = [],
88
}: {
99
plugin: IPlugin;
10-
images: string[];
10+
images: { link: string; internal: boolean }[];
1111
} = $props();
1212
</script>
1313

1414
<div class="mb-image-card-grid">
1515
{#each images as image}
16-
<ImageCard plugin={plugin} image={image}></ImageCard>
16+
<ImageCard plugin={plugin} image={image.link} internal={image.internal}></ImageCard>
1717
{/each}
1818
</div>

0 commit comments

Comments
 (0)