Adding Photos to Tables in DataviewJs?

Things I have tried

Here is where I’ve gotten as far as the code goes, but is not working/is breaking.

for (let group of dv.pages("#TFT/Character and #TFT").where(b => b.Seer).groupBy(p => p.Seer)) {
	dv.header(2, group.key);
	dv.table(["Photo", "Name", "Status"],
		group.rows
			.map(k => ['![photo|90](" +' k.photo '+ ")', k.file.link, k.Status]))
}

What I’m trying to do

I’m trying to add photos to a table rendered using DataviewJS. I’ve figured out how to do this in the standard dataview query language:

TABLE WITHOUT ID
 ("![photo|90](" + photo + ")") as Photo, file.link as "Name", Age, Summary, Status
FROM #TFT/Character 
WHERE contains(Role, "Hero")
SORT file.ctime asc

But haven’t been able to replicate the behavior in JS (I’m admittedly not too well-versed in Javascript). You can see the code snippet that I’ve tried (which is not valid/working/breaks) above.

Any help would be greatly appreciated!

I’m a zero in JS, but considering the similar logic with DQL (standard dataview queries) I think you messed up with the quotes.
Try this: .map(k => ["![photo|90](" + k.photo + ")", k.file.link, k.Status]))

1 Like

@mnvwvnm to the rescue again. Thanks so much for your help. I really appreciate it!

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.