When it comes to quickly pulling in images into my org documents, org-download
is superb. This package is a critical part of my workflow and I use it daily on my Windows work system.
Having a Windows system at work1 means that some of the cool functions that work with org-download
do not function due to the limitation put on my by corporate policy. One of those is pasting images from the clipboard. This is very annoying as I often take screenshots that I want to pull into notes. If I take a screenshot I have to clip that, save it to a folder, find that folder on my screen then line up a drag and drop - turning each image insert into a hassle. Especially if you are taking notes during a presentation or lecture.
The below modification2 to the org-download-image
function solves that by always looking for an image file in the same place - specified as ~/file1.png
in line 4 - change this to what ever works best for you.
I can now save my screen clips as the file specified above, run M-x TJ/org-download-image
3 and org-download
will find it, save it into the right structure and display it in my org file. I can confidently save over the file with the next clipping knowing that everything has been filed correctly.
(defun TJ/org-download-image ()
"Save image from '~/file1.png' to `org-download--dir'."
(interactive)
(let* ((link "~/file1.png")
(link-and-ext (org-download--parse-link link))
(filename
(cond ((and (derived-mode-p 'org-mode)
(eq org-download-method 'attach))
(let ((org-download-image-dir (org-attach-dir t))
org-download-heading-lvl)
(apply #'org-download--fullname link-and-ext)))
((fboundp org-download-method)
(funcall org-download-method link))
(t
(apply #'org-download--fullname link-and-ext)))))
(setq org-download-path-last-file filename)
(org-download--image link filename)
(when (org-download-org-mode-p)
(when (eq org-download-method 'attach)
(org-attach-attach filename nil 'none))
(org-download-insert-link link filename))
(when (and (eq org-download-delete-image-after-download t)
(not (url-handler-file-remote-p (current-kill 0))))
(delete-file link delete-by-moving-to-trash))))