lucaorio / obsidian-image-gallery

A zero setup masonry image gallery for Obsidian
MIT License
195 stars 15 forks source link

FR: Relative path #27

Open gerroon opened 10 months ago

gerroon commented 10 months ago

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 commented 5 months ago

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 commented 5 months ago

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 commented 5 months ago

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

theebio commented 5 months ago

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.