Function: org-odt-link--inline-image
org-odt-link--inline-image is a byte-compiled function defined in
ox-odt.el.gz.
Signature
(org-odt-link--inline-image ELEMENT INFO)
Documentation
Return ODT code for an inline image.
LINK is the link pointing to the inline image. INFO is a plist used as a communication channel.
Source Code
;; Defined in /usr/src/emacs/lisp/org/ox-odt.el.gz
(defun org-odt-link--inline-image (element info)
"Return ODT code for an inline image.
LINK is the link pointing to the inline image. INFO is a plist
used as a communication channel."
(cl-assert (eq (org-element-type element) 'link))
(let* ((src (let* ((type (org-element-property :type element))
(raw-path (org-element-property :path element)))
(cond ((member type '("http" "https"))
(concat type ":" raw-path))
((file-name-absolute-p raw-path)
(expand-file-name raw-path))
(t raw-path))))
(src-expanded (if (file-name-absolute-p src) src
(expand-file-name src (file-name-directory
(plist-get info :input-file)))))
(href (format
"\n<draw:image xlink:href=\"%s\" xlink:type=\"simple\" xlink:show=\"embed\" xlink:actuate=\"onLoad\"/>"
(org-odt--copy-image-file src-expanded)))
;; Extract attributes from #+ATTR_ODT line.
(attr-from (cl-case (org-element-type element)
(link (org-export-get-parent-element element))
(t element)))
;; Convert attributes to a plist.
(attr-plist (org-export-read-attribute :attr_odt attr-from))
;; Handle `:anchor', `:style' and `:attributes' properties.
(user-frame-anchor
(car (assoc-string (plist-get attr-plist :anchor)
'(("as-char") ("paragraph") ("page")) t)))
(user-frame-style
(and user-frame-anchor (plist-get attr-plist :style)))
(user-frame-attrs
(and user-frame-anchor (plist-get attr-plist :attributes)))
(user-frame-params
(list user-frame-style user-frame-attrs user-frame-anchor))
;; (embed-as (or embed-as user-frame-anchor "paragraph"))
;;
;; Handle `:width', `:height' and `:scale' properties. Read
;; them as numbers since we need them for computations.
(size (org-odt--image-size
src-expanded info
(let ((width (plist-get attr-plist :width)))
(and width (read width)))
(let ((length (plist-get attr-plist :length)))
(and length (read length)))
(let ((scale (plist-get attr-plist :scale)))
(and scale (read scale)))
nil ; embed-as
"paragraph" ; FIXME
))
(width (car size)) (height (cdr size))
(standalone-link-p (org-odt--standalone-link-p element info))
(embed-as (if standalone-link-p "paragraph" "as-char"))
(captions (org-odt-format-label element info 'definition))
(caption (car captions))
(entity (concat (and caption "Captioned") embed-as "Image"))
;; Check if this link was created by LaTeX-to-PNG converter.
(replaces (org-element-property
:replaces (if (not standalone-link-p) element
(org-export-get-parent-element element))))
;; If yes, note down the type of the element - LaTeX Fragment
;; or LaTeX environment. It will go in to frame title.
(title (and replaces (capitalize
(symbol-name (org-element-type replaces)))))
;; If yes, note down its contents. It will go in to frame
;; description. This quite useful for debugging.
(desc (and replaces (org-element-property :value replaces))))
(org-odt--render-image/formula entity href width height
captions user-frame-params title desc)))