]> git.eshelyaron.com Git - emacs.git/commitdiff
Treat SVG images like other image types in 'shr-put-image'
authorJim Porter <jporterbugs@gmail.com>
Thu, 11 Jul 2024 23:29:37 +0000 (16:29 -0700)
committerEshel Yaron <me@eshelyaron.com>
Sat, 13 Jul 2024 20:07:48 +0000 (22:07 +0200)
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 (bug#71913).

* lisp/net/shr.el (shr-put-image): Don't special-case SVGs.

(cherry picked from commit f38c42d1c7a8413f63b1e56261850d3dbe8abef8)

lisp/net/shr.el

index 39271cc52960024efc78e9301c83e570c7a20b40..d3c48b344286b190530799c026a8e3c8c98cb97b 100644 (file)
@@ -1193,23 +1193,18 @@ You can specify the following optional properties:
   (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.