Function: org-export-link-localise

org-export-link-localise is a byte-compiled function defined in ox.el.gz.

Signature

(org-export-link-localise LINK)

Documentation

Convert remote LINK to local link.

If LINK refers to a remote resource, modify it to point to a local downloaded copy. Otherwise, return unchanged LINK.

Source Code

;; Defined in /usr/src/emacs/lisp/org/ox.el.gz
(require 'subr-x) ;; FIXME: For `thread-first' in Emacs 26.
(defun org-export-link-localise (link)
  "Convert remote LINK to local link.
If LINK refers to a remote resource, modify it to point to a local
downloaded copy.  Otherwise, return unchanged LINK."
  (when (org-export-link-remote-p link)
    (let* ((local-path (org-export-link--remote-local-copy link)))
      (if local-path
          (setcdr link
                  (thread-first (cadr link)
                                (plist-put :type "file")
                                (plist-put :path local-path)
                                (plist-put :raw-link (concat "file:" local-path))
                                list))
        (display-warning
         '(org export)
         (format "unable to obtain local copy of %s"
                 (org-element-property :raw-link link))))))
  link)