Function: gnus-html-put-image
gnus-html-put-image is a byte-compiled function defined in
gnus-html.el.gz.
Signature
(gnus-html-put-image DATA URL &optional ALT-TEXT)
Documentation
Put an image with DATA from URL and optional ALT-TEXT.
Source Code
;; Defined in /usr/src/emacs/lisp/gnus/gnus-html.el.gz
(defun gnus-html-put-image (data url &optional alt-text)
"Put an image with DATA from URL and optional ALT-TEXT."
(when (display-graphic-p)
(let* ((start (text-property-any (point-min) (point-max)
'image-url url))
(end (when start
(next-single-property-change start 'image-url))))
;; Image found?
(when start
(let* ((image
(ignore-errors
(gnus-create-image data nil t)))
(size (and image (image-size image t))))
(save-excursion
(goto-char start)
(let ((alt-text (or alt-text
(buffer-substring-no-properties start end)))
(inhibit-read-only t))
(if (and image
;; Kludge to avoid displaying 30x30 gif images, which
;; seems to be a signal of a broken image.
(not (and (listp image)
(eq (plist-get (cdr image) :type)
'gif)
(= (car size) 30)
(= (cdr size) 30))))
;; Good image, add it!
(let ((image (gnus-rescale-image image (gnus-html-maximum-image-size))))
(delete-region start end)
(gnus-put-image image alt-text 'external)
(make-text-button start (point)
'help-echo alt-text
'keymap gnus-html-displayed-image-map)
(put-text-property start (point) 'gnus-alt-text alt-text)
(when url
(add-text-properties
start (point)
`(image-url
,url
image-displayer
(lambda (url start end)
(gnus-html-display-image url start end
,alt-text)))))
(gnus-add-image 'external image)
t)
;; Bad image, try to show something else
(when (fboundp 'find-image)
(delete-region start end)
(setq image (find-image
'((:type xpm :file "lock-broken.xpm"))))
(gnus-put-image image alt-text 'internal)
(gnus-add-image 'internal image))
nil))))))))