xpgo / obsidian-folder-note-plugin

Plugin to add description note to a folder for Obsidian.
385 stars 27 forks source link

Problem to correct process {{FOLDER_BRIEF}} or {{FOLDER_BRIEF_LIVE}} when using new location for attachments #66

Open cladic opened 1 year ago

cladic commented 1 year ago

If I change the default behavior of Obsidian by using "Files & Links : -> Default location for new attachments = In the folder specified below
-> Attachement folder path = #Pics ( we need to manually create this FOLDER to works well when we pasted an image for example... )

the {{FOLDER_BRIEF_LIVE}} or {{FOLDER_BRIEF}} does not works correctly. In fact, do not use the correct PATH of attachments ( pictures pasted ) as was set before.

How it is now ( the wrong way ):


items: [
  {
    title: 'Note-1',
    link: 'Folder-1/Note-1.md',
    brief: 'assasa',
    foot: '10/12/2022, 7:39:08 PM',
    image: 'Pasted image 20221012193906.png'
  },

How should de the correct way:

```ccard
items: [
  {
    title: 'Note-1',
    link: 'Folder-1/Note-1.md',
    brief: 'assasa',
    foot: '10/12/2022, 7:39:08 PM',
    image: '/#Pics/Pasted image 20221012193906.png'
  },

================

In some place somebody tells about using the parameter "imagePrefix"....

On the link about "ccard sample recipes" ( https://github.com/xpgo/obsidian-folder-note-plugin/blob/main/doc/ccard-recipes.md ) there is an instruction saying:

      _If you want to use the imagePrefix in every folder note, you could insert the above code blocks into the initial content of folder note by the Folder Note Plugin settings.

      For statically defined item data:

      ​```ccard
      items: [
        {
          title: 'note 1',
          image: 'image1.png'
        }
      ]
      imagePrefix: 'assets/'
      ​```_
But I can not understand exactly where I need to change or insert this code. On the "Folder Note plugin options" I can not see a place to do this....The "Initial Content" does not accept this kind of configuration....If I put the "imagePrefix" in this place then the final result is that the parameter stays outside of ```card ...```` section.

If we in fact have this option to do the configuration of the PATH of the files then does somebody could show me the correct procedure in detail to execute this solution ?

Thanks in advance 

Observation: I resolved the problem by doing a PATCH directly on the "main.js" code:

Insert after line 267 this code => imagePrefix = "#Pics//";

               ...
               // asset file name?
                var imageUrl = this.headImage;
        imagePrefix = "#Pics//";                               <====
                if (imagePrefix.length > 0) {
              ....
It is not a good solution but it is the only way I have now to fix it.

Do not forget to reload the Obsidian before using the plugin after the patch was applied.
georgebyte commented 1 year ago

To set the imagePrefix through plugin settings, replace the content of "Initial Content" textarea with:

```ccard
type: folder_brief_live
imagePrefix: 'assets/'


Using the default `{{FOLDER_BRIEF_LIVE}}` keyword doesn't let you modify the contents of `ccard` block, it is just replaced with `\n```ccard\ntype: folder_brief_live\n```\n` in code: https://github.com/xpgo/obsidian-folder-note-plugin/blob/272bbdc9a674fd333e6a97b02611868797648585/src/folder-note.ts#L258

cc @cladic @benjacob