From d53dc5e22d6ebd7905c194b9dcd006e763a1aa3d Mon Sep 17 00:00:00 2001 From: Artur Malabarba Date: Sat, 24 Jan 2015 02:52:09 -0200 Subject: Only shrink images, don't enlarge them. --- sx-question-print.el | 16 +++++++++++++--- 1 file 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." -- cgit v1.2.3