(shr-put-image): Add help-echo alt texts to the images.
[gnus] / lisp / shr.el
index 324bbee..3e6dbb8 100644 (file)
@@ -370,18 +370,17 @@ redirects somewhere else."
           (let ((alt (buffer-substring start end))
                (inhibit-read-only t))
            (delete-region start end)
-           (shr-put-image data start alt))))))
+           (goto-char start)
+           (shr-put-image data alt))))))
   (kill-buffer (current-buffer)))
 
-(defun shr-put-image (data point alt)
+(defun shr-put-image (data alt)
   (if (display-graphic-p)
       (let ((image (ignore-errors
                      (shr-rescale-image data))))
         (when image
-          (put-image image point alt)))
-    (save-excursion
-      (goto-char point)
-      (insert alt))))
+         (insert-image image (or alt "*"))))
+    (insert alt)))
 
 (defun shr-rescale-image (data)
   (if (or (not (fboundp 'imagemagick-types))
@@ -471,14 +470,6 @@ Return a string with image data."
 (defun shr-tag-s (cont)
   (shr-fontize-cont cont 'strike-through))
 
-(defun shr-tag-span (cont)
-  (let ((start (point))
-       (color (cdr (assq 'color (shr-parse-style (cdr (assq :style cont)))))))
-    (shr-generic cont)
-    (when color
-      (let ((overlay (make-overlay start (point))))
-       (overlay-put overlay 'face (cons 'foreground-color color))))))
-
 (defun shr-parse-style (style)
   (when style
     (let ((plist nil))
@@ -520,6 +511,10 @@ Return a string with image data."
        (when (zerop (length alt))
          (setq alt "[img]"))
        (cond
+        ((or (member (cdr (assq :height cont)) '("0" "1"))
+             (member (cdr (assq :width cont)) '("0" "1")))
+         ;; Ignore zero-sized or single-pixel images.
+         )
         ((and (not shr-inhibit-images)
               (string-match "\\`cid:" url))
          (let ((url (substring url (match-end 0)))
@@ -527,7 +522,7 @@ Return a string with image data."
            (if (or (not shr-content-function)
                    (not (setq image (funcall shr-content-function url))))
                (insert alt)
-             (shr-put-image image (point) alt))))
+             (shr-put-image image alt))))
         ((or shr-inhibit-images
              (and shr-blocked-images
                   (string-match shr-blocked-images url)))
@@ -537,17 +532,17 @@ Return a string with image data."
                (shr-insert (substring alt 0 8))
              (shr-insert alt))))
         ((url-is-cached (shr-encode-url url))
-         (shr-put-image (shr-get-image-data url) (point) alt))
+         (shr-put-image (shr-get-image-data url) alt))
         (t
          (insert alt)
          (ignore-errors
            (url-retrieve (shr-encode-url url) 'shr-image-fetched
                          (list (current-buffer) start (point-marker))
                          t))))
-       (insert " ")
        (put-text-property start (point) 'keymap shr-map)
        (put-text-property start (point) 'shr-alt alt)
        (put-text-property start (point) 'shr-image url)
+       (put-text-property start (point) 'help-echo alt)
        (setq shr-state 'image)))))
 
 (defun shr-tag-pre (cont)