copy-selection-as-markdown icon indicating copy to clipboard operation
copy-selection-as-markdown copied to clipboard

optionally embedd images as base64

Open alexanderadam opened this issue 5 years ago • 8 comments
trafficstars

It's possible to embed images via data URLs in base64. For example

![Image](data:image/png;base64,SOMEBASE64STRING)

It would be nice if copy-selection-as-markdown would support this functionality as well. This way it would be easier to have a full backup of an article that might be deleted later on, including it's resources.

PS: Thank you for this extension :pray: PPS: There are also browser extensions like img2base64, that allow to copy an image as base64 directly. Maybe it would be possible to take that logic from there?

alexanderadam avatar Sep 07 '20 14:09 alexanderadam

There's also a tool for backing up Medium articles called medup that's doing this. What I like about the approach in medup is, that the images are only inlined at the end and there are only references to them within the regular text flow.

alexanderadam avatar Oct 01 '20 14:10 alexanderadam

@alexanderadam: Thanks a lot for your suggestion! I don't have your use case but interesting enhancement. challenge accepted!

0x6b avatar Oct 03 '20 12:10 0x6b

Will update this issue after release.

0x6b avatar Oct 09 '20 06:10 0x6b

@alexanderadam: Just released v0.20.4 which contains this feature. Grub your update and let me know if you found any issue. Thanks!

0x6b avatar Oct 09 '20 07:10 0x6b

Check Embed imgs (.gif, .jpg, .jpeg, .png, and .webp) as base64 text as possible at Advanced setting to enable the feature. It requires additional permission to access referenced images.

0x6b avatar Oct 09 '20 07:10 0x6b

@0x6b, Thank you so much for working on this. :raised_hands: Unfortunately it didn't work properly when I just tested this. I marked your avatar here on this issue page and I got a reference but it wasn't base64 encoded.

It looks like this:

[![@0x6b][img1]](https://github.com/0x6b) [ 0x6b](https://github.com/0x6b)

[img1]: https://avatars0.githubusercontent.com/u/679719?s=40&v=4

EDIT: Maybe it's a permission thing because it's working perfectly on other sites! I accepted the permission to access everything but it's not appearing at the listed permissions (only Input data to the clipboard is listed.):

Permissions of copy-selection-as-markdown

alexanderadam avatar Oct 09 '20 08:10 alexanderadam

Maybe I somehow misunderstand the optional permission concept. I also see permission error in the console like:

Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at https://github.githubassets.com/images/spinners/octocat-spinner-32.gif. (Reason: CORS header ‘Origin’ cannot be added).

Will work on this again. Thanks for testing!

EDIT: Easiest solution is to add <all_urls> permission request by default, but it's too open for advanced options.

0x6b avatar Oct 09 '20 09:10 0x6b

Easiest solution is to add <all_urls> permission request by default, but it's too open for advanced options.

I absolutely agree and I value your concerns in this regards. :+1: More people should focus which permissions their extension or app is using.

alexanderadam avatar Oct 09 '20 09:10 alexanderadam