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

FR: Relative path #27

Open
gerroon opened this issue Dec 6, 2023 · 5 comments
Open

FR: Relative path #27

gerroon opened this issue Dec 6, 2023 · 5 comments

Comments

@gerroon
Copy link

gerroon commented Dec 6, 2023

Hi

It would be very helpful if it accepts relative (to the current note) path, the absolute path makes it a right requirement.

Maybe something like this

->folder
-->assets
-->gallery.md

gallery.md

```img-gallery
path: ./assets
type: horizontal
@theebio
Copy link

theebio commented Apr 18, 2024

if you are still looking for relative path for this I needed it for my vault and got it working well enough. Here is the changes to the main.ts file in the .obsidian/plugins folder

replace:
settings.path = (0, import_obsidian2.normalizePath)(settingsSrc.path);

with:
const currentFilePath = this.app.workspace.getActiveFile().path;
const currentDir = currentFilePath.substring(0, currentFilePath.lastIndexOf('/'));
settings.path = import_obsidian2.normalizePath(currentDir + "/" + settingsSrc.path);

@kyleyoungblom
Copy link

Once that's added to the .js what do you put for the path in the data block in your Obsidian file? I tried . and currentDir/currentFilePath.

@gerroon
Copy link
Author

gerroon commented Apr 29, 2024

Why not do a pull request? That would be very nice addition.

@theebio
Copy link

theebio commented Apr 29, 2024

Once that's added to the .js what do you put for the path in the data block in your Obsidian file? I tried . and currentDir/currentFilePath.

After I put that in the main.js I use paths like this:
If you just want to display images in the same dir "path: /"
if you want to display images in a dir in the same dir as the note "path: /dir1"

I also took all the plugin files and edited them myself to make a sort of "custom" plugin lol. Dont know if that is required.

Why not do a pull request? That would be very nice addition.

I just wanted to share my findings to help out. Just doing the bare minimum atm lol. Feel free to take my tiny changes and create a more organized way of sharing them.

@gerroon
Copy link
Author

gerroon commented Oct 14, 2024

Thanks for the fix. It seems to work for relative folders, but I am not a dev and I would not know how to do this in an actual TS file to do a pull request:(

It would be nice also it accepts regular relative (./images) absolute path (/imgaes) syntax.

Once that's added to the .js what do you put for the path in the data block in your Obsidian file? I tried . and currentDir/currentFilePath.

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

No branches or pull requests

3 participants