Function: org-link-preview-file
org-link-preview-file is a byte-compiled function defined in ol.el.gz.
Signature
(org-link-preview-file OV PATH LINK)
Documentation
Display image file PATH in overlay OV for LINK.
LINK is the Org element being previewed.
Equip each image with the keymap image-map.
This is intended to be used as the :preview link property of
file links, see org-link-parameters.
Source Code
;; Defined in /usr/src/emacs/lisp/org/ol.el.gz
(defun org-link-preview-file (ov path link)
"Display image file PATH in overlay OV for LINK.
LINK is the Org element being previewed.
Equip each image with the keymap `image-map'.
This is intended to be used as the `:preview' link property of
file links, see `org-link-parameters'."
(when (display-graphic-p)
(require 'image)
(when-let* ((file-full (expand-file-name path))
(file (substitute-in-file-name file-full))
((string-match-p (image-file-name-regexp) file))
((file-exists-p file)))
(let* ((width (org-display-inline-image--width link))
(align (org-image--align link))
(image (org--create-inline-image file width)))
(when image ; Add image to overlay
;; See bug#59902. We cannot rely
;; on Emacs to update image if the file
;; has changed.
(image-flush image)
(overlay-put ov 'display image)
(overlay-put ov 'face 'default)
(overlay-put ov 'keymap image-map)
(when align
(overlay-put
ov 'before-string
(propertize
" " 'face 'default
'display
(pcase align
("center" `(space :align-to (- center (0.5 . ,image))))
("right" `(space :align-to (- right ,image)))))))
t)))))