diff options
author | Artur Malabarba <bruce.connor.am@gmail.com> | 2015-01-24 02:52:09 -0200 |
---|---|---|
committer | Artur Malabarba <bruce.connor.am@gmail.com> | 2015-01-24 02:52:09 -0200 |
commit | d53dc5e22d6ebd7905c194b9dcd006e763a1aa3d (patch) | |
tree | 855af0ba2ca5f944638888226eb46e3b2b0133f0 /sx-question-print.el | |
parent | 62592e73af739b898fa401fd3c3503f43e8bb267 (diff) |
Only shrink images, don't enlarge them.
Diffstat (limited to 'sx-question-print.el')
-rw-r--r-- | sx-question-print.el | 16 |
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." |