Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Image links show up in file.outlinks #449

Open
shtu-cham opened this issue Aug 25, 2021 · 21 comments
Open

Image links show up in file.outlinks #449

shtu-cham opened this issue Aug 25, 2021 · 21 comments
Assignees
Labels
help Help with dataview features.

Comments

@shtu-cham
Copy link

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 shtu-cham added the feature-request New feature or request. label Aug 25, 2021
@blacksmithgu
Copy link
Owner

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 blacksmithgu added this to the 0.4.6 milestone Aug 25, 2021
@shtu-cham
Copy link
Author

shtu-cham commented Aug 25, 2021

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!

@blacksmithgu
Copy link
Owner

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.

@shtu-cham
Copy link
Author

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.

@blacksmithgu
Copy link
Owner

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 blacksmithgu removed this from the 0.4.6 milestone Sep 9, 2021
@blacksmithgu blacksmithgu added help Help with dataview features. and removed feature-request New feature or request. labels Sep 9, 2021
@shtu-cham
Copy link
Author

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.

@blacksmithgu
Copy link
Owner

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
Copy link
Owner

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.

@shtu-cham
Copy link
Author

shtu-cham commented Sep 12, 2021

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!

@blacksmithgu
Copy link
Owner

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")

@shtu-cham
Copy link
Author

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!

@blacksmithgu blacksmithgu changed the title Ask for without grammar support or global filter Image links show up in file.outlinks Sep 12, 2021
@tzhouhc
Copy link

tzhouhc commented Dec 5, 2021

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))

@EMBuwel
Copy link

EMBuwel commented Feb 14, 2023

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 !

@abonhote
Copy link

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.

@karlnovel
Copy link

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!

@aboode95
Copy link

aboode95 commented Sep 2, 2023

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?

@AB1908
Copy link
Collaborator

AB1908 commented Sep 2, 2023

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

@aboode95
Copy link

aboode95 commented Sep 2, 2023

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 ^^

@AB1908
Copy link
Collaborator

AB1908 commented Sep 3, 2023

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

@Slender4fun
Copy link

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.

@TangentFoxy
Copy link

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help Help with dataview features.
Projects
None yet
Development

No branches or pull requests