Function: markdown--image-media-handler

markdown--image-media-handler is a natively compiled function defined in markdown-mode.el.

Signature

(markdown--image-media-handler MIMETYPE DATA)

Source Code

;; Defined in /nix/store/p33zgg95aglc47pl6zlgs43vki0snxf8-emacs-packages-deps/share/emacs/site-lisp/elpa/markdown-mode-20260827.909/markdown-mode.el
(defun markdown--image-media-handler (mimetype data)
  (let* ((ext (symbol-name (mailcap-mime-type-to-extension mimetype)))
         (filename (read-string "Insert filename for image: "))
         (link-text (read-string "Link text: "))
         (filepath (file-name-with-extension filename ext))
         (dir (file-name-directory filepath)))
    (when (and dir (not (file-directory-p dir)))
      (make-directory dir t))
    (with-temp-file filepath
      (insert data))
    (when (string-match-p "\\s-" filepath)
      (setq filepath (concat "<" filepath ">")))
    (markdown-insert-inline-image link-text filepath)))