[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [O] Drag images from Firefox to org-mode

From: Xebar Saram
Subject: Re: [O] Drag images from Firefox to org-mode
Date: Wed, 16 Oct 2013 16:22:06 +0200

Thx Oleh ,This is really amazing!

Ive been waiting for ages for something like this. a few questions (well ok "requests" :)..) if you dont mind. please bare in mind i have zero coding skills (or understanding so my questions may be stupid :))

1.i use alot of images and :in alot of headings and sub headings and the current method creates tens of folders. can you make an option to store all images in a central location, IE ~/org/images? also Torstens suggestion of adding a date to the file name makes alot of sense :)

2.can you add an option to add a local file (IE drag a jpg/png from a folder) or even better yet build into the script a screenshot ability function (using scrot etc) like in the following script:


3.maybe perhaps a text scraper that would do the same for formatted text, so one would mark a section in the browser, and drag it into org (and the script would automagicly would get rid of the html yuckyness << notice my highly technical coding terms and knowledge)

best and thanks alot!


On Wed, Oct 16, 2013 at 4:48 PM, Torsten Wagner <torsten.wagner@gmail.com> wrote:
This looks like a nice feature!
Maybe you could add to save the address and date the picture was taken, thus, one could easily refer to the image origin. That is sometimes of importance.
Thanks for sharing


On 16 October 2013 12:04, Oleh <address@hidden> wrote:
Hi all,

Here's a little hack that I use to make my life easier:

(require 'async)
  (require 'cl))
(defun org-store-image (link basedir)
   `(lambda() (shell-command
          ,(format "wget \"%s\" -P \"%s\""
                   (expand-file-name basedir))))
   (lexical-let ((cur-buf (current-buffer)))
       (with-current-buffer cur-buf

(defun org-store-image-clipboard (link)
  "Save image at address LINK to current directory's subdirectory DIR.
DIR is the name of the current level 0 heading."
  (interactive (list (current-kill 0)))
  (let ((filename (car (last (split-string link "/"))))
        (dir (save-excursion
               (org-up-heading-all (1- (org-current-level)))
    (if (null (image-type-from-file-name filename))
        (message "not an image URL")
      (unless (file-exists-p (expand-file-name filename dir))
        (org-store-image link dir))
      (insert (format "[[./%s/%s]]" dir filename))

(setcdr (assoc "^\\(https?\\|ftp\\|file\\|nfs\\)://" dnd-protocol-alist) 'dnd-org-insert)

(defun dnd-org-insert (uri action)
  (org-store-image-clipboard uri))

When it's a plain image, I can just drag it from the browser to org-mode. 
It will be downloaded in async to a subdirectory of the current directory and the link will be inserted 
at point. 
For stubborn images that are links I can right click to copy image location and call
`org-store-image-clipboard' interactively.

I hope it's useful to someone and that I'm not re-implementing standard functionality.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]