obsidian-share-as-gist icon indicating copy to clipboard operation
obsidian-share-as-gist copied to clipboard

Linked images...

Open olearydj opened this issue 2 years ago • 8 comments

Hello, Tim.

First, thank you for this incredibly useful plugin. I find myself using it to draft feedback for students more and more. The ability to do that in Obsidian and push it to github is really terrific.

I wonder if it could support embedded images? I typically use the ![[image.png]] embedding style but am happy to use a different method.

You can find an example post here, where I've resorted to pasting the image in a comment as a workaround: https://gist.github.com/4d06d592f0b0ae1771c0012de3562d8d

Regardless, many thanks again.

Dan

olearydj avatar Nov 01 '22 16:11 olearydj

Thanks for reaching out! 👋🏻 Are the images coming from your local machine?

timrogers avatar Nov 01 '22 16:11 timrogers

Yes, local images. Given how easy it is to drag and drop images into the GH interface, with links auto-created, I hoped that the API you are using would facilitate the same.

olearydj avatar Nov 01 '22 17:11 olearydj

Unfortunately, I don't believe that there is a way to do this in the API. We would have to host the images somewhere else externally.

timrogers avatar Nov 18 '22 07:11 timrogers

That’s a shame. Thank you for considering it. I wonder if something like the approach used in this recently released plugin would work? It uses a “data url” to include images in html without generating an external link.

https://github.com/mvdkwast/obsidian-copy-as-html

olearydj avatar Nov 19 '22 14:11 olearydj

Unfortunately, I don't believe that there is a way to do this in the API. We would have to host the images somewhere else externally.

@timrogers Why not simply upload the embedded images as files on the Gist?

devnoname120 avatar Apr 30 '23 10:04 devnoname120

Unfortunately, I don't believe that there is a way to do this in the API. We would have to host the images somewhere else externally.

@timrogers Why not simply upload the embedded images as files on the Gist?

I haven't checked in detail, but is that supporter? Once you've uploaded them, can you embed them?

timrogers avatar Apr 30 '23 14:04 timrogers

I haven't checked in detail, but is that supporter? Once you've uploaded them, can you embed them?

Using git add/commit/push it works. See this Gist for an example: https://gist.github.com/devnoname120/32d3a6a2b93bdbe47652038739b815b0

You could use https://github.com/isomorphic-git/isomorphic-git to run Git commands. This is the approach taken by obsidian-git


Unfortunately uploading binary files directly through the Git REST API isn't supported. The closest I got is:

jq --raw-input --slurp '{"description":"Example of a gist","public":false,"files":{"image.png":{"content": .}}}' image.png |  curl -L \
  -X POST \
  -H "Authorization: Bearer [REDACTED]"\
  -H "X-GitHub-Api-Version: 2022-11-28" \
  https://api.github.com/gists \
  -d @-

However the uploaded image.png is broken: all the non-valid UTF-8 characters are removed.

devnoname120 avatar May 01 '23 09:05 devnoname120

I haven't checked in detail, but is that supporter? Once you've uploaded them, can you embed them?

Using git add/commit/push it works. See this Gist for an example: https://gist.github.com/devnoname120/32d3a6a2b93bdbe47652038739b815b0

You could use https://github.com/isomorphic-git/isomorphic-git to run Git commands. This is the approach taken by obsidian-git

Can you share a detailed guide? The images links used in obsidian [[aa.png]] are in some way automatically modified or you have to edit it manually?

inode- avatar Feb 19 '24 09:02 inode-