Function: eca-chat--build-inline-image

eca-chat--build-inline-image is a natively compiled function defined in eca-chat-image.el.

Signature

(eca-chat--build-inline-image IMAGE-CONTENT)

Documentation

Return an Emacs image object for IMAGE-CONTENT, or nil.

Returns nil on TTY frames or when the media type is unsupported. IMAGE-CONTENT is a plist with :mediaType and :base64 keys.

Source Code

;; Defined in /nix/store/jklqzw6pzz6j4jrbv8wy0iwgi7jlrbld-emacs-packages-deps/share/emacs/site-lisp/elpa/eca-20260928.1827/eca-chat-image.el
(defun eca-chat--build-inline-image (image-content)
  "Return an Emacs image object for IMAGE-CONTENT, or nil.
Returns nil on TTY frames or when the media type is unsupported.
IMAGE-CONTENT is a plist with `:mediaType' and `:base64' keys."
  (when-let* (((display-graphic-p))
              (b64 (plist-get image-content :base64))
              (binary (base64-decode-string b64))
              (image-type (eca-chat--image-type-from-media-type
                           (plist-get image-content :mediaType))))
    (let ((max-w (eca-chat--resolve-image-max-width)))
      (apply #'create-image binary image-type t
             (append
              (when max-w (list :max-width max-w))
              (when eca-chat-image-max-height
                (list :max-height eca-chat-image-max-height)))))))