How to show all #software notes in Dataview, displaying images if present, but still listing notes without images?

I want to display in a dataview table all the files that have the tag #software and in case the note has an image in the img property, display the image.
This is the code I use:

TABLE embed(link(meta(img).path,"50")) as "img"
FROM #software

Unfortunately, using this code, the dataview table displays only notes that have BOTH #software tag and an image in the img property.

Instead, I would like to display also files that have #software tag but don’t have an image in the img property.

How can I achieve this?

Thank you

Try TABLE WITHOUT ID and then add a note column like file.name AS "Note" in a TABLE row.

Cheers, Marko :nerd_face:

1 Like

Thank you but the dataview table still doesn’t show the notes that haven’t an image in the img Properties.

To be more clear I show my exact case with images.
This note has an image in img property:

And it is displayed as expected in the dataview table:
image

While this note hasn’t an image in the img property and for some reason isn’t displayed on my dataview table:

This is the full code I use:

TABLE embed(link(meta(img).path,"50")) as "img",rating,os,description
FROM #software
WHERE !contains(lower(file.folder), "template")
SORT file.ctime DESC

If I remove embed(link(meta(img).path,"50")) as "img" even the notes without images are displayed correctly.
I think that, to make it work, I have to add some code that if there isn’t an image in “img”, then ignore embed(link(meta(img).path,"50")) as "img". But I don’t know how to achieve it.

OK, in Dataview you have choice(bool, left, right)Functions - Dataview … instead of if.

choice(img, embed(link(meta(img).path, "50")), "") AS "Image"

If there’s an image, show it; else, show “empty/null”. Try to go in this direction. Not behind my computer, so can’t test it :frowning:

Cheers, Marko :nerd_face:

1 Like

Thank you, I tried using choice but the results with no image still don’t appear. This is the code I tried:

TABLE choice(img, embed(link(meta(img).path,"50")), "") as "img",rating,os,description
FROM #software
WHERE !contains(lower(file.folder), "template")
SORT file.ctime DESC

Your issue most likely arises from the fact that you’re trying to do meta(img).path when img is empty, which trigger an exception causing those rows to be removed.

Try replacing it with something like: meta( default(img, "...dummyImg...")).path where the dummy img is some valid link to an image in your vault to be used as a placeholder image.

2 Likes

Thank you very much, it works!

This is the code I’ve used:

TABLE embed(link(meta( default(img, [[NoImageAvailable.png]])).path,"50")) as "img",rating,os,description
FROM #software
WHERE !contains(lower(file.folder), "template")
SORT file.ctime DESC

Dataview now shows also no image notes:

2 Likes

I’m encountering a new problem.
I’m trying to use DataviewJS to embed the images stored in the img property and display them at a width of 50 pixels.

This is the code I am trying but it doesn’t work:

dv.table(["FILE", "IMAGES"],dv.pages("#software").map(b => [b.file.link,embed(link(meta( default(b.img, ![[NoImageAvailable.png]])).path,"50"))]))

Why doesn’t it work? The functions on here (like link, meta and default) don’t work on dataviewjs?

Thank you

When you’re in dataviewjs you’ll need to use the javascript variants of functions:

You can to some extent use the dv.func.XXX to access the DQL variant of a function, but there might be some variations in how to work with a given function. DQL is a different beast when compared to dataviewjs.