Visuwesh <visuwe...@gmail.com> writes: > This was far easier than I initially thought. Patch attached.
Thanks! I tried to install the patch and I have two more comments. > +(defun org-yank-image-autogen-filename () > + "Autogenerate filename for image in clipboard." > + (format-time-string "clipboard-%Y-%m-%d-%H:%M")) This is too coarse - no more than a single unique image name per minute. What about the default value of `org-id-ts-format' - "%Y%m%dT%H%M%S.%6N"? This is guaranteed to be unique. > +(defun org--image-yank-media-handler (mimetype data) > + "Save image DATA of mime-type MIMETYPE and insert link at point. > +It is saved as per `org-yank-image-save-type'. The name for the > +image is prompted and the extension is automatically added to the > +end." > ... > + (if (null (eq org-yank-image-save-type 'attach)) > + (setq link (org-link-make-string > + (concat "file:" (file-relative-name absname)) > + filename)) I do not like that the inserted image link is with description. Images with description cannot be previewed by default. I think that no description would be more handy as one could then M-x yank-media followed by M-x org-display-inline-images to see the inserted image immediately. > + (org-link-make-string > + (concat (if separatep > + "file:" > + "attachment:") > + (if separatep > + (expand-file-name (file-name-nondirectory filename) > + org-yank-image-save-type) > + (file-name-nondirectory filename))) Same here. -- Ihor Radchenko // yantar92, Org mode contributor, Learn more about Org mode at <https://orgmode.org/>. Support Org development at <https://liberapay.com/org-mode>, or support my work at <https://liberapay.com/yantar92>