obsidian-dataview icon indicating copy to clipboard operation
obsidian-dataview copied to clipboard

Image links show up in `file.outlinks`

Open shtu-cham opened this issue 4 years ago • 21 comments

Is your feature request related to a problem? Please describe. I would use without grammar in any other columns, but the only way I found to use the without method was for ID. For example, I am writing notes with the help of obsidian and dataview. During this process, when I am writing notes, also using dataview to generate my MOC table, so I will take file.inlink and outlink into consideration. While I try to do that, I notice that the MOC appears in each file.inlink rows, so I want to exclude it.

Describe the solution you'd like Provide the without grammar support for it, then I can append it in my dataview code.

Describe alternatives you've considered Provide the filter which allows people freely filter the elements they don't want.

Additional context

shtu-cham avatar Aug 25 '21 03:08 shtu-cham

The WITHOUT ID grammar is to get rid of the hard-coded "File" field if you want to use something else, it's not a filter operator.

If you want to filter, you probably want the filter function:

TABLE filter(file.inlinks, (l) => l != [[Link To MOC]]) AS "Links", ...

blacksmithgu avatar Aug 25 '21 04:08 blacksmithgu

The WITHOUT ID grammar is to get rid of the hard-coded "File" field if you want to use something else, it's not a filter operator.

If you want to filter, you probably want the filter function:

TABLE filter(file.inlinks, (l) => l != [[Link To MOC]]) AS "Links", ...

Thank you for your reply. Yes, I might want this. To be specified, I just want to control the content of table. Like I said before, in order to realize the connection of each file, I would love to do it with the help of dv. However, if all the files are connected to the MOC, and the filter might filter everything, then I won't see anything from the table. So I just need to let the MOC don't show up in file.inlink column.

Furthermore, when I insert a picture in the file, the name of the png will show up in the outlink column too. To focus on the link between points, I also want to exclude this kind of information.

Thank you for your hard work!

shtu-cham avatar Aug 25 '21 04:08 shtu-cham

I'm not fully understanding what you are looking for. The brief example I gave will, for each file, list all of it's incoming links except a specific MOC. Is it not giving the output you want?

Image links showing up in file.outlinks is a bug; I will fix it for the next release.

blacksmithgu avatar Aug 26 '21 18:08 blacksmithgu

I'm not fully understanding what you are looking for. The brief example I gave will, for each file, list all of it's incoming links except a specific MOC. Is it not giving the output you want?

Image links showing up in file.outlinks is a bug; I will fix it for the next release.

Emm, sorry to bother you. I did copy the code to my ob, and changed the content of [[Link to MOC]] to the name of my MOC. Still the MOC will appear in my file.inlink column. Did I use it in the wrong way? Thank you for your patience.

shtu-cham avatar Aug 27 '21 04:08 shtu-cham

Can you share the exact query you are using? I was able to filter out the MOC when I tried doing this locally, so it may be a difference in our queries.

blacksmithgu avatar Sep 09 '21 04:09 blacksmithgu

Can you share the exact query you are using? I was able to filter out the MOC when I tried doing this locally, so it may be a difference in our queries.

I called it SoilMachinicsMOC. So I use the code below. dataview TABLE filter(file.inlinks, (l) => l != [[SoilMachinicsMOC]]) AS "Links",title,tags,aliases,file.inlinks,file.outlinks,file.link from "Soil" where contains(tags,"Machinics") image Though, it still show up in table.

shtu-cham avatar Sep 11 '21 04:09 shtu-cham

You have file.inlinks in the table twice - once as the filtered column ("Links"), and then again later on without the filter. Is there a reason for having both? You should only need the first one.

blacksmithgu avatar Sep 11 '21 20:09 blacksmithgu

For context, filter only affects the value you are filtering, not other columns. So

TABLE filter(file.inlinks, (l) => l != [[Link]]), file.inlinks

Will only filter the first column, not the second one.

blacksmithgu avatar Sep 11 '21 20:09 blacksmithgu

For context, filter only affects the value you are filtering, not other columns. So

TABLE filter(file.inlinks, (l) => l != [[Link]]), file.inlinks

Will only filter the first column, not the second one.

Thank you, now I see the way of using it. According to your guide, I rewrite it below, put the file.inlinks column to the fourth.

TABLE 
title,tags,aliases,filter(file.inlinks, (4)=>4 != [[SoilMachinicsMOC]]) AS "Links",file.outlinks,file.link
from "Soil"
where contains(tags,"Machinics")

Then it comes back to me with error.

Expected one of the following: '(', 'null', boolean, date, duration, file link, list ('[1, 2, 3]'), negated field, number, object ('{ a: 1, b: 2 }'), string, variable

Could you please help with this error? Much appreciate it!

shtu-cham avatar Sep 12 '21 00:09 shtu-cham

This is a little advanced, which is why it may be confusing - the error is in the 4; instead of 4, use x (the thing you replaced with 4 is a variable, which cannot start with a number).

TABLE 
title,tags,aliases,filter(file.inlinks, (x)=>x != [[SoilMachinicsMOC]]) AS "Links",file.outlinks,file.link
from "Soil"
where contains(tags,"Machinics")

blacksmithgu avatar Sep 12 '21 07:09 blacksmithgu

This is a little advanced, which is why it may be confusing - the error is in the 4; instead of 4, use x (the thing you replaced with 4 is a variable, which cannot start with a number).

TABLE 
title,tags,aliases,filter(file.inlinks, (x)=>x != [[SoilMachinicsMOC]]) AS "Links",file.outlinks,file.link
from "Soil"
where contains(tags,"Machinics")

Thank you, now I correct my dataview code and it works! I noticed dataview was updated to 0.4.8, yet the name of the png still show up in the outlink column. I am looking forward to seeing it fixed.

Again, thank you for your amazing work!

shtu-cham avatar Sep 12 '21 16:09 shtu-cham

I'd love if we get .file.allOutlinks that also include dangling links and images and web links, and then the old .file.outlinks that are just the regular wikilinks to files.

This quirk bit me in the butt today when I tried to do an outlinks.every(l => dv.page(l.path))

tzhouhc avatar Dec 05 '21 00:12 tzhouhc

Hello,

The file.outlinks is still showing links to attached documents (images, email...) and not only between .md files, is it still planned to correct it ? Or is there a new outlinks metadata to exclude it ?

Thanks !

EMBuwel avatar Feb 14 '23 21:02 EMBuwel

I'm not fully understanding what you are looking for. The brief example I gave will, for each file, list all of it's incoming links except a specific MOC. Is it not giving the output you want?

Image links showing up in file.outlinks is a bug; I will fix it for the next release.

Hi!

It seems they're still there (or maybe again?). I tried to filter them out using

filter(file.outlinks, (x) => !contains(x,".png"))

That didn't work either. Any idea welcome.

abonhote avatar Mar 15 '23 14:03 abonhote

I'm not fully understanding what you are looking for. The brief example I gave will, for each file, list all of it's incoming links except a specific MOC. Is it not giving the output you want? Image links showing up in file.outlinks is a bug; I will fix it for the next release.

Hi!

It seems they're still there (or maybe again?). I tried to filter them out using

filter(file.outlinks, (x) => !contains(x,".png"))

That didn't work either. Any idea welcome.

Hey!

I got i working with filter(file.outlinks, (x) => !contains(string(x), "png"))

Hope that helps!

karlnovel avatar Aug 26 '23 12:08 karlnovel

How to write filter(file.outlinks, (x) => !contains(string(x), "png")) for dataviewjs?

I tried:

dv.filter(dv.current().file.outlinks, (x) => !contains(string(x), "png"))

shows error: TypeError: dv.filter is not a function

And I can't see a documentation on filter in dataviewjs... where can I find that?

aboode95 avatar Sep 02 '23 10:09 aboode95

dv.current().file.outlinks.where(x => !x.path.endsWith("png"))

AB1908 avatar Sep 02 '23 11:09 AB1908

dv.current().file.outlinks.where(x => !x.path.endsWith("png"))

Thank you @AB1908! that worked!

Hey, btw, is there a documentation for these codes? Like, where did you find the path.endsWith() function? I am a bit new to this so don't really know where to look. Would appreciate the guidance ^^

aboode95 avatar Sep 02 '23 12:09 aboode95

That's just regular javascript. Use MDN. Also, toying around in the developer console is supremely helpful.

AB1908 avatar Sep 03 '23 11:09 AB1908

dv.current().file.outlinks.where(x => !x.path.endsWith("png"))

sorry guys, i'm pretty new to all the languages that are used in Obsidian. How do i use this snippet?

this is my Querry so far:

TABLE WITHOUT ID
	file.link AS "Dateiname", dateformat(file.mtime, "HH:mm D") AS "Bearbeitet", file.outlinks AS "Linkt zu"

WHERE !contains(file.outlink, ".png")

SORT
	file.mtime desc

"WHERE !contains(file.outlink, ".png")" does not work atm.

Slender4fun avatar Sep 25 '23 17:09 Slender4fun

I'm a little confused, how is showing links to images in queries a bug? If I linked to an image, it should show up in links.

Did you mean embedded images are showing up as links?

TangentFoxy avatar Apr 05 '24 17:04 TangentFoxy