aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--sx-question-print.el16
1 files changed, 13 insertions, 3 deletions
diff --git a/sx-question-print.el b/sx-question-print.el
index fe34d9c..3a2eedf 100644
--- a/sx-question-print.el
+++ b/sx-question-print.el
@@ -399,13 +399,23 @@ Image links are downloaded and displayed, if
(sx-question-mode--insert-link
(if (and sx-question-mode-use-images (eq ?! (elt full-text 0)))
;; Is it an image?
- (create-image (sx-request-get-url url) 'imagemagick t
- :width (min sx-question-mode-image-max-width
- (window-body-width nil 'pixel)))
+ (sx-question-mode--create-image url)
;; Or a regular link
(or (if sx-question-mode-pretty-links text full-text) url))
url))))))))
+(defun sx-question-mode--create-image (url)
+ "Get and create an image from URL.
+Its size is bound by `sx-question-mode-image-max-width' and
+`window-body-width'."
+ (let* ((image
+ (create-image (sx-request-get-url url) 'imagemagick t))
+ (image-width (car (image-size image 'pixels))))
+ (append image
+ (list :width (min sx-question-mode-image-max-width
+ (window-body-width nil 'pixel)
+ image-width)))))
+
(defun sx-question-mode--insert-link (text-or-image url)
"Return a link propertized version of TEXT-OR-IMAGE.
URL is used as 'help-echo and 'url properties."