markoff icon indicating copy to clipboard operation
markoff copied to clipboard

Unable to embed local images

Open dgsmith opened this issue 9 years ago • 6 comments

I've got a very simple Markdown file to test this out that just has ![test image](md_assets/tank1.png) in it. I put the file tank1.png in a folder called md_assets in the same directory as this test.md file. I then open with Markoff and I see...

tank image fails to load

Then, I use Markdown Preview in my Sublime Text editor and see...

tank image successfully loaded

Not sure if this is fixed by switching to SwiftMark...but I've installed the latest version from the App Store and am seeing this problem. Thanks!

edit: worth noting that I am able to load external images, and I have tried using the full path to my image.

dgsmith avatar Mar 03 '16 20:03 dgsmith

Thanks for reporting. This is a duplicate of #2.

kaishin avatar Mar 05 '16 11:03 kaishin

I was unable to figure out a clean of way of doing this in a sandboxed application. If anyone has any suggestions I'd be happy to take them.

kaishin avatar Apr 01 '16 13:04 kaishin

Hit the same issue today with local images... I don't know anything about Cocoa, but maybe a solution would be to change the current working directory to the Markdown file directory when preview is triggered? Maybe then relative paths would render fine, but that's not a very educated guess.

pch avatar Jul 04 '16 14:07 pch

See this has been idle for a while, but Markoff could detect that opening an image falied and ask the user for permission on the enclosing folder. The Unarchiver does this for the Downloads directory the first time it is run. See https://stackoverflow.com/questions/12771375/what-does-a-mac-sandboxed-app-get-access-to-when-the-user-selects-a-folder

Side note: just stumbled across Markoff and it's exactly what I want in a previewer. Hoping this can be fixed.

blezek avatar Oct 10 '17 17:10 blezek

Though not perfect, I'm using this way to solve the problem:

  1. Organize all md files under one root dir, e.g. /home/mitnk/docs/

  2. Always run a http server (using python etc) under this dir.

nohup python3 -m http.server -b 127.0.0.1 -d /home/mitnk/docs 9901 > /dev/null &

Use a fixed port and remember it. Use nohup here so that we can close terminal without terminate the http server.

  1. Drafting doc in one of sub dir, e.g. /home/mitnk/docs/design/foobar.md

  2. Drop your images under some sub dir, say docs/design/img/001-logo.png

  3. Now we can insert your image into foobar.md file like this:

![img](http://127.0.0.1:9901/desgin/img/001-logo.png)

or control the image size with raw html:

<img src="http://127.0.0.1:9901/desgin/img/001-logo.png", width="200">

Should work with Markoff now. (Yes, this way I've replaced Evernote with Dropbox/git :-)

mitnk avatar May 24 '19 09:05 mitnk

As I am starting work on 2.0 and 3.0, I have been thinking about this. I still haven't figured a proper solution but I've got some ideas. Stay tuned.

kaishin avatar Jul 08 '20 21:07 kaishin