Function: message-toggle-image-thumbnails
message-toggle-image-thumbnails is an interactive and byte-compiled
function defined in message.el.gz.
Signature
(message-toggle-image-thumbnails)
Documentation
For any included image files, insert a thumbnail of that image.
Key Bindings
Source Code
;; Defined in /usr/src/emacs/lisp/gnus/message.el.gz
(defun message-toggle-image-thumbnails ()
"For any included image files, insert a thumbnail of that image."
(interactive nil message-mode)
(let ((displayed nil))
(save-excursion
(goto-char (point-min))
(while (not (eobp))
(when-let* ((props (get-text-property (point) 'display)))
(when (and (consp props)
(eq (car props) 'image))
(put-text-property (point) (1+ (point)) 'display nil)
(setq displayed t)))
(forward-char 1)))
(unless displayed
(save-excursion
(goto-char (point-min))
(while (re-search-forward "<img.*src=\"\\([^\"]+\\).*>" nil t)
(let ((string (match-string 0))
(file (match-string 1))
(edges (window-inside-pixel-edges
(get-buffer-window (current-buffer)))))
(delete-region (match-beginning 0) (match-end 0))
(insert-image
(create-image
file 'imagemagick nil
:max-width (truncate
(* 0.7 (- (nth 2 edges) (nth 0 edges))))
:max-height (truncate
(* 0.5 (- (nth 3 edges) (nth 1 edges)))))
string)))))))