Björn Bidar <bjorn.bi...@thaodan.de> writes:

>>> The thing that confused me, but I think I wasn't aware of not getting it
>>> yesterday was that org--create-inline-image creates the actual image
>>> object. I was thinking that the image object would have been created in the
>>> handler and then passed to the helper function.
>>
>> Feel free to improve the docstring.
>> I do agree that it may be confusing.
>
> create-image uses the term file-or-data instead of file would that be better?

Maybe simply say

(defun org--create-inline-image (file width)
  "Create image object for FILE, or return nil.

>> Also, we need to explain the possible values of ALIGN and WIDTH.
>> Maybe even provide some defaults (maybe even via cl-defun)
>
> Would it make sense to provide defaults for ALIGN and WIDTH when they
> have to be supplied or be derived from link?

Right. It would not.

> @@ -2178,23 +2178,39 @@ (defun org-link-preview-file (ov path link)
>  
>  This is intended to be used as the `:preview' link property of
>  file links, see `org-link-parameters'."
> -  (when (display-graphic-p)
> -    (require 'image)
>      (when-let* ((file-full (expand-file-name path))
>                  (file (substitute-in-file-name file-full))
>                  ((string-match-p (image-file-name-regexp) file))
>                  ((file-exists-p file)))
> -      (let* ((width (org-display-inline-image--width link))
> -          (align (org-image--align link))
> -             (image (org--create-inline-image file width)))
> -        (when image            ; Add image to overlay
> -       ;; See bug#59902.  We cannot rely
> +       (org-link-preview-image-data ov file link)))
> +
> +(defun org-link-preview-image-data (ov image-data &optional link align width)
> +  "Display raw image data IMAGE-DATA in overlay OV for LINK.
> ...

I am looking at this and wonder why not simply change the whole
org-link-preview file to have (ov image-data-or-path &optional link align width)
arguments. Then, we can make `org-link-preview-image-data' internal and
only expose `org-link-preview-file' as the API function.

-- 
Ihor Radchenko // yantar92,
Org mode maintainer,
Learn more about Org mode at <https://orgmode.org/>.
Support Org development at <https://liberapay.com/org-mode>,
or support my work at <https://liberapay.com/yantar92>

Reply via email to