1
Fork 0
mirror of git://git.sv.gnu.org/emacs.git synced 2026-01-30 04:10:54 -08:00

image-type-from-file-name fix for bug#9045

* lisp/image.el (image-type-from-file-name): If multiple types match,
return the first one that is supported.
This commit is contained in:
Glenn Morris 2012-10-22 20:46:11 -04:00
parent f961c7d82b
commit ea1d4aaca0
2 changed files with 16 additions and 2 deletions

View file

@ -1,3 +1,8 @@
2012-10-23 Glenn Morris <rgm@gnu.org>
* image.el (image-type-from-file-name): If multiple types match,
return the first one that is supported. (Bug#9045)
2012-10-22 Glenn Morris <rgm@gnu.org>
* image.el (imagemagick-enabled-types): Doc fix.

View file

@ -308,8 +308,17 @@ be determined."
"Determine the type of image file FILE from its name.
Value is a symbol specifying the image type, or nil if type cannot
be determined."
(assoc-default file image-type-file-name-regexps 'string-match-p))
(let (type first)
(or
(catch 'found
(dolist (elem image-type-file-name-regexps)
(when (string-match-p (car elem) file)
(setq type (cdr elem))
(or first (setq first type))
(if (image-type-available-p type)
(throw 'found type)))))
;; If nothing seems to be supported, return the first type that matched.
first)))
;;;###autoload
(defun image-type (source &optional type data-p)