lang/org: improve error handling for remote image previews
This commit is contained in:
parent
b2927955e7
commit
936f13744b
1 changed files with 7 additions and 7 deletions
|
@ -73,13 +73,13 @@
|
|||
(defun +org-image-link (protocol link _description)
|
||||
"Interpret LINK as base64-encoded image data."
|
||||
(when (image-type-from-file-name link)
|
||||
(let ((buf (url-retrieve-synchronously (concat protocol ":" link))))
|
||||
;; TODO Better error handling
|
||||
(cl-assert buf nil "Download of image \"%s\" failed." link)
|
||||
(with-current-buffer buf
|
||||
(goto-char (point-min))
|
||||
(re-search-forward "\r?\n\r?\n")
|
||||
(buffer-substring-no-properties (point) (point-max))))))
|
||||
(if-let* ((buf (url-retrieve-synchronously (concat protocol ":" link))))
|
||||
(with-current-buffer buf
|
||||
(goto-char (point-min))
|
||||
(re-search-forward "\r?\n\r?\n" nil t)
|
||||
(buffer-substring-no-properties (point) (point-max)))
|
||||
(message "Download of image \"%s\" failed" link)
|
||||
nil)))
|
||||
|
||||
(org-link-set-parameters "http" :image-data-fun #'+org-image-link)
|
||||
(org-link-set-parameters "https" :image-data-fun #'+org-image-link)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue