From 70ecc19f735e0cea0fda8721d7f2709c39f1bbff Mon Sep 17 00:00:00 2001 From: Jim Porter Date: Thu, 11 Jul 2024 16:29:37 -0700 Subject: [PATCH] Treat SVG images like other image types in 'shr-put-image' For both SVG and no-SVG builds, this works as expected (in the no-SVG case, it would raise an error which subsequently gets ignored). However, compared to the previous implementation, this lets users resize SVG images just like every other image type. * lisp/net/shr.el (shr-put-image): Don't special-case SVGs. --- lisp/net/shr.el | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/lisp/net/shr.el b/lisp/net/shr.el index 39271cc5296..d3c48b34428 100644 --- a/lisp/net/shr.el +++ b/lisp/net/shr.el @@ -1193,23 +1193,18 @@ shr-put-image (if (display-graphic-p) (let* ((zoom (or (plist-get flags :zoom) (car shr-image-zoom-levels))) - (zoom-function (nth 2 (assq zoom shr-image-zoom-level-alist))) + (zoom-function (or (nth 2 (assq zoom shr-image-zoom-level-alist)) + (error "Unrecognized zoom level %s" zoom))) (data (if (consp spec) (car spec) spec)) (content-type (and (consp spec) (cadr spec))) (start (point)) - (image (cond - ((eq content-type 'image/svg+xml) - (when (image-type-available-p 'svg) - (create-image data 'svg t :ascent shr-image-ascent))) - (zoom-function - (ignore-errors - (funcall zoom-function data content-type - (plist-get flags :width) - (plist-get flags :height)))) - (t (error "Unrecognized zoom level %s" zoom))))) + (image (ignore-errors + (funcall zoom-function data content-type + (plist-get flags :width) + (plist-get flags :height))))) (when image ;; The trailing space can confuse shr-insert into not ;; putting any space after inline images. -- 2.25.1