如何通过dataviewjs显示符合检索条件的文件中的所有图片
比如,设置检索式 xxx,符合条件的文件有 A 、B
最后结果显示 A、B中的所有图片
如何通过dataviewjs显示符合检索条件的文件中的所有图片
比如,设置检索式 xxx,符合条件的文件有 A 、B
最后结果显示 A、B中的所有图片
图片本质是md文件的出链,获取file.outlink就行,但是用dv渲染图片有点复杂,可能得用embed函数,还得自己研究一下才行
怎么通过检索式获得匹配文件的出链
感谢启发,原来图片可以直接当成出链获取!
编写了个脚本,有需求的话可以参考下
注:
reverse(file.outlinks)[0]
表示取排序后的第1个元素,即图片,然后嵌入到Dataview列表中table
embed(link(reverse(file.outlinks)[0], "100")) as 封面,
tags as 标签
from -"ZZZ_Obsidian_File"
sort file.mtime desc
limit 50
embed(link(filter(file.outlinks, (x) => icontains(x+"1", ".jpg") or icontains(x+"1", ".png"))[0], "100")) as 封面,
楼主看我新发的评论,可以参考一下
可以的,多谢了。
你好,我想问一下,dataview能不能限定某一列的宽度,比如说cover这一列,限定他的宽度为200。
用css好像可以
You can set a minimum table width using a css snippet (a .css file saved in \.obsidian\snippets\), I use the following one:
.table-view-table td:nth-child(1) {
min-width: 120px;
}
.table-view-table td:nth-child(2) {
min-width: 60px;
}
You might have to modify the min-width to fit your own minimum value and change the number of the column to three, so probably around:
.table-view-table td:nth-child(3) {
min-width: 100px;
}