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

[Bug]: <img>'s src aren't getting a base path correctly (attachmentLinks) #32

Closed
3 tasks done
kurko opened this issue Oct 9, 2022 · 8 comments
Closed
3 tasks done
Assignees

Comments

@kurko
Copy link
Contributor

kurko commented Oct 9, 2022

Issue validation

Workflow

Obsidian plugin 💠

Describe the bug

tl;dr with Default Attachment Folder (defaultImageFolder) set to images/obsidian, dev console shows that convertLinkCitation ignores that and returns images/naming.png instead of images/obsidian/naming.png .

It seemed to be similar to #8, which was supposed to be fixed by 0755d37, but it wasn't.

Upon investigation, I think the culprit is this line. It was supposed to be using the default attachment path and is not. It's returning images/naming.png

Screen Shot 2022-10-08 at 23 46 28

You can see in the generated PR that the image path is correctly images/obsidian/naming.png, but the markdown file itself is not including obsidian/ in src.

How to reproduce ?

  1. Set a default attachment folder (defaultImageFolder)
  2. publish
  3. the image tag doesn't have its path modified to include the attachment folder. It ignores it completely.

Configuration

{
  "githubRepo": "blog",
  "githubName": "kurko",
  "GhToken": "ghp_[REDACTED]",
  "shareKey": "share",
  "ExcludedFolder": "",
  "fileMenu": true,
  "editorMenu": true,
  "downloadedFolder": "fixed",
  "folderDefaultName": "obsidian",
  "yamlFolderKey": "",
  "rootFolder": "",
  "workflowName": "",
  "embedImage": true,
  "defaultImageFolder": "images/obsidian",
  "autoCleanUp": true,
  "autoCleanUpExcluded": "",
  "folderNote": false,
  "convertWikiLinks": true,
  "convertForGithub": true,
  "subFolder": "",
  "embedNotes": false,
  "copyLink": false,
  "mainLink": "",
  "linkRemover": "",
  "hardBreak": false,
  "logNotice": false,
  "convertDataview": true,
  "useFrontmatterTitle": true,
  "censorText": [
    {
      "entry": "\\]\\(\\.\\/",
      "replace": "]({% link obsidian/"
    },
    {
      "entry": "\\({% link(.*)\\)",
      "replace": "({% link $1.md %})"
    }
  ],
  "inlineTags": false,
  "dataviewFields": [],
  "excludeDataviewValue": [],
  "metadataFileFields": [
    "obsidian"
  ],
  "frontmatterTitleKey": "filename",
  "shareExternalModified": false
}

Relevant log output

No response

OS

MacOS

Anything else?

Minor feedback: the lack of tests make it difficult to contribute

@kurko kurko added the bug label Oct 9, 2022
@kurko
Copy link
Contributor Author

kurko commented Oct 9, 2022

Found the culprit: apparently targetList.filter((x) => !sourceList.includes(x)) is removing the word obsidian from images/obsidian/naming.png. I don't understand why it needs to drop a directory, unsure whether it's a feature for something else or a bug.

Here's the screenshot with all values. Notice at the end, it drops the directory:

Screen Shot 2022-10-09 at 00 07 24

Can you advise on how to fix this? I'm afraid it'd break other things that are expected somewhere else 😬 This is the last remaining block to get my blog to get published from Obsidian 😄

@Mara-Li
Copy link
Member

Mara-Li commented Oct 9, 2022

I Will check that ! Don't worry :D

@Mara-Li Mara-Li closed this as completed in 06bd9be Oct 9, 2022
@Mara-Li
Copy link
Member

Mara-Li commented Oct 9, 2022

I pushed a beta version of this fix, could you please try it and keep me informed about it ?

@kurko
Copy link
Contributor Author

kurko commented Oct 9, 2022

I can confirm it worked with 4.3.7-0 (beta) 😄

@kurko
Copy link
Contributor Author

kurko commented Oct 9, 2022

I noticed now that links aren't working, and I think it might be due to this change (need to confirm).

Here's my config:

Screen Shot 2022-10-09 at 19 03 06


Here is the screenshot in Obsidian showing from about (source) to my-digital-workbench (target).

Screen Shot 2022-10-09 at 19 08 49

Note that:

  • the my-digital-workbench file has frontmatter filename: _pages/my-digital-workbench (with _pages),
  • the file is deployed to obsidian/_pages/my-digital-workbench as expected,
  • but the final link in about points to obsidian/my-digital-workbench, omitting _pages.

@Mara-Li
Copy link
Member

Mara-Li commented Oct 10, 2022

As I can see, It's not a markdown or wikilinks no ? My regex for internal links only work on these

@kurko
Copy link
Contributor Author

kurko commented Oct 15, 2022

Hm... yes it is. If you check again this image, the wikilink [[my-digital-workbench|Check out my work setup]] on the bottom right pane is a link.

@BluesDriveAmelia
Copy link

This seems to be the same issue I'm currently struggling with. The image links in my posts start with "/posts/" but the images are at the same link but without that. I was actually following your blog post, @kurko, though what I assume was the solution you figured out (the text replacer) has not been working for me. Any ideas?

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