bordaigorl / sublime-evernote

Open and Save Evernote notes from Sublime Text 3 using Markdown
Other
1.15k stars 104 forks source link

Feature request: How can I use image hash to find original image and upload it to own image server? #144

Closed JimmyLv closed 8 years ago

JimmyLv commented 8 years ago

For example, I got this en-media tag which include a hash attribute 85c3bddc274983b97656f96d921e2f5c, and I want to replace it with standard Markdown syntax like

![](http://example.com/images/85c3bddc274983b97656f96d921e2f5c)

so that I can upload the original image if I can find it in my local Evernote database folder.

<en-media hash="85c3bddc274983b97656f96d921e2f5c" width="2048" height="1287" type="image/jpeg" style="cursor: default;cursor: default;"/>
bordaigorl commented 8 years ago

I am not sure I understand your question. What are you trying to accomplish? If you know the hash of the attachment of a note, you can insert an en-media tag manually in the markdown of that same note. If you want to insert an image that is an attachment of note A, into note B using the hash does not work and you would need to attach the same image to the other note as well. Another option is using note links.

Right now markdown images only work for externally hosted images. Attached images only work by using the en-media tag. The plugin is meant to work as a thin client for Evernote so without relying on a local database, nor the local database of another Evernote client installed in the same machine. I am not planning to support any interaction with these local database unless there is a very well motivated use-case.

JimmyLv commented 8 years ago

Hi @bordaigorl,

Thanks for your reply so quickly! Let me clarify my requirement and what I want to implement again, I am sorry for that if anything does not make sense.

Okay, actually I want to change the enmd syntax to standard Markdown syntax which has image url like ![]() rather than attached images, so that I can save the whole md content as my blog post resource which can be parsed by jekyll or hexo directly.

So, I need convert an image en-media tag to ![]() url, of course at the same time, I need find the original image and upload it to my own image server, then I can get the image url.

Finally, the question becomes that, how can I find the original image in my local database, just by the hash value inside en-media tag because it is the only different identifier between different en-media tag.

bordaigorl commented 8 years ago

Hi,

I do not know how the data is stored in the local database. This is also going to be platform specific and my change from client version to client version.

If I was you, I would do the following:

  1. Do not use attachments for images
  2. Upload your static assets (the images) in the website before writing the note/post. Then you locate them in the server using an url (example: http://www.mywebsite.com/images/something.png) then you use that url in the markdown as follows:
![something](http://www.mywebsite.com/images/something.png)

This should work as you expect, showing the image both in the Evernote Client and in your rendered website.

JimmyLv commented 8 years ago

Hi, @bordaigorl

Yes, you are correct. I just want to make all my existing notes from EverNote to local md files, but still storage a copy in EverNote for more comfortable previewing. So I am trying another way to do that: using any script to convert the exported Notes.enex from XML to MD files, then upload static assets (the images) and replace these urls in md files, finally storage these md files to EverNote one by one using your sublime plugin.

So, btw: Can I use the sublime-evernote to upload multiple notes at the same time?

bordaigorl commented 8 years ago

@JimmyLv

Can I use the sublime-evernote to upload multiple notes at the same time?

In principle yes: you can write your own plugin that opens a list of files with the note's contents and issues a view.run_command('send_to_evernote') for each view. If you instead want to update existing notes the process is more involved, as you have to know the note's guid and make the plugin set the $evernote_guid and $evernote_title (hidden) view settings to the appropriate values before issuing a save_evernote_note command. This would overwrite your cloud-stored note based on the guid, so use with care.