Add inline remote image display

* lisp/org.el (org-display-inline-images): Add inline remote image
display. Remote image display is controlled by the new option
`org-display-remote-inline-images'.
This commit is contained in:
Jack Kamm 2020-02-01 11:50:08 +01:00 committed by Nicolas Goaziou
parent f704904737
commit dcdb470177
2 changed files with 52 additions and 5 deletions

View File

@ -49,6 +49,12 @@ things in a property drawer before the first headline will make them
After editing a source block, Org will restore the window layout when
~org-src-window-setup~ is set to a value that modifies the layout.
*** Display remote inline images
Added the capability to display remote images inline. Whether the
images are actually displayed are controlled by the new option
~org-display-remote-inline-images~.
*** Babel: new header argument to pass Java command line arguments
Babel Java blocks recognize header argument =:cmdargs= and pass its

View File

@ -16781,6 +16781,51 @@ INCLUDE-LINKED is passed to `org-display-inline-images'."
;; For without-x builds.
(declare-function image-refresh "image" (spec &optional frame))
(defcustom org-display-remote-inline-images 'skip
"How to display remote inline images.
Possible values of this option are:
skip Don't display remote images.
download Always download and display remote images.
cache Display remote images, and open them in separate buffers
for cacheing. Silently update the image buffer when a file
change is detected."
:group 'org-appearance
:package-version '(Org . "9.4")
:type '(choice
(const :tag "Ignore remote images" skip)
(const :tag "Always display remote images" download)
(const :tag "Display and silently update remote images" cache))
:safe #'symbolp)
(defun org--create-inline-image (file width)
"Create image located at FILE, or return nil.
WIDTH is the width of the image. The image may not be created
according to the value of `org-display-remote-inline-images'."
(let* ((remote? (file-remote-p file))
(file-or-data
(pcase org-display-remote-inline-images
((guard (not remote?)) file)
(`download (with-temp-buffer
(set-buffer-multibyte nil)
(insert-file-contents-literally file)
(buffer-string)))
(`cache (let ((revert-without-query '(".")))
(with-current-buffer (find-file-noselect file)
(buffer-string))))
(`skip nil)
(other
(message "Invalid value of `org-display-remote-inline-images': %S"
other)
nil))))
(when file-or-data
(create-image file-or-data
(and (image-type-available-p 'imagemagick)
width
'imagemagick)
remote?
:width width))))
(defun org-display-inline-images (&optional include-linked refresh beg end)
"Display inline images.
@ -16899,11 +16944,7 @@ buffer boundaries with possible narrowing."
'org-image-overlay)))
(if (and (car-safe old) refresh)
(image-refresh (overlay-get (cdr old) 'display))
(let ((image (create-image file
(and (image-type-available-p 'imagemagick)
width 'imagemagick)
nil
:width width)))
(let ((image (org--create-inline-image file width)))
(when image
(let ((ov (make-overlay
(org-element-property :begin link)