* Link preview generation with new link preview property
@ 2024-12-08 19:18 Björn Bidar
0 siblings, 0 replies; 4+ messages in thread
From: Björn Bidar @ 2024-12-08 19:18 UTC (permalink / raw)
To: emacs-orgmode
Hello,
I have a few question regarding the new link preview handler property
added recently. I ported the org-remoteimg package to it which was quite
easy, much cleaner with the new property.
The PR do port the package to this new handler property:
https://github.com/gaoDean/org-remoteimg/pull/4
However it left me with a few questions:
- Who is supposed to take care of the scaling/width of the preview
image, the handler or the caller of the handler?
- When calling the link preview function for a description with prefix
argument 1 I noticed that it doesn't get the contents of the
description.
Why is that? In this instance the link looked like this:
[[https://stable.melpa.org/#/rpm-spec-mode][file:https://stable.melpa.org/packages/rpm-spec-mode-badge.svg]]
Thanks have a great day,
Björn
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Link preview generation with new link preview property
[not found] <6755f138.0c0a0220.40388.51fbSMTPIN_ADDED_BROKEN@mx.google.com>
@ 2024-12-13 5:49 ` Karthik Chikmagalur
2024-12-14 0:03 ` Björn Bidar
0 siblings, 1 reply; 4+ messages in thread
From: Karthik Chikmagalur @ 2024-12-13 5:49 UTC (permalink / raw)
To: Björn Bidar, emacs-orgmode
> The PR do port the package to this new handler property:
> https://github.com/gaoDean/org-remoteimg/pull/4
>
> However it left me with a few questions:
> - Who is supposed to take care of the scaling/width of the preview
> image, the handler or the caller of the handler?
The handler is responsible for sizing the image. The reason for this is
that the preview does not have to be an image -- it can be any kind of
overlay decoration.
If you decide to use an image file as the preview, you can call
`org-link-preview-file' inside your handler to handle the geometry for
you. This includes the size and alignment specified by #+attr_*
keywords, `org-image-max-width' and `org-image-align'.
If you are using a preview image from image data, you'll have to copy
some of the code in `org-link-preview-file' to your handler if you want
to respect these user options.
> - When calling the link preview function for a description with prefix
> argument 1 I noticed that it doesn't get the contents of the
> description.
> Why is that? In this instance the link looked like this:
> [[https://stable.melpa.org/#/rpm-spec-mode][file:https://stable.melpa.org/packages/rpm-spec-mode-badge.svg]]
I don't follow. What do you mean by "it doesn't get the contents"? Did
the preview work as expected when you used a prefix arg of 1?
Karthik
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Link preview generation with new link preview property
2024-12-13 5:49 ` Link preview generation with new link preview property Karthik Chikmagalur
@ 2024-12-14 0:03 ` Björn Bidar
2024-12-14 7:04 ` Ihor Radchenko
0 siblings, 1 reply; 4+ messages in thread
From: Björn Bidar @ 2024-12-14 0:03 UTC (permalink / raw)
To: Karthik Chikmagalur; +Cc: emacs-orgmode
Karthik Chikmagalur <karthikchikmagalur@gmail.com> writes:
>> The PR do port the package to this new handler property:
>> https://github.com/gaoDean/org-remoteimg/pull/4
>>
>> However it left me with a few questions:
>> - Who is supposed to take care of the scaling/width of the preview
>> image, the handler or the caller of the handler?
>
> The handler is responsible for sizing the image. The reason for this is
> that the preview does not have to be an image -- it can be any kind of
> overlay decoration.
>
> If you decide to use an image file as the preview, you can call
> `org-link-preview-file' inside your handler to handle the geometry for
> you. This includes the size and alignment specified by #+attr_*
> keywords, `org-image-max-width' and `org-image-align'.
>
> If you are using a preview image from image data, you'll have to copy
> some of the code in `org-link-preview-file' to your handler if you want
> to respect these user options.
Would it be possible to also handle image data in the function or
refactor the org-link-preview-file function in a way that the geometry
handling is done in a helper function which can be reused by other
handlers.
In the example I mentioned it should be possible to use the cached file
from the url cache but that might be not so easy in other cases.
>> - When calling the link preview function for a description with prefix
>> argument 1 I noticed that it doesn't get the contents of the
>> description.
>> Why is that? In this instance the link looked like this:
>> [[https://stable.melpa.org/#/rpm-spec-mode][file:https://stable.melpa.org/packages/rpm-spec-mode-badge.svg]]
>
> I don't follow. What do you mean by "it doesn't get the contents"? Did
> the preview work as expected when you used a prefix arg of 1?
The link element passed towards the handler didn't contain the
description e.g. in this case file:https://stable.melpa.org/packages/rpm-spec-mode-badge.svg.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Link preview generation with new link preview property
2024-12-14 0:03 ` Björn Bidar
@ 2024-12-14 7:04 ` Ihor Radchenko
0 siblings, 0 replies; 4+ messages in thread
From: Ihor Radchenko @ 2024-12-14 7:04 UTC (permalink / raw)
To: Björn Bidar; +Cc: Karthik Chikmagalur, emacs-orgmode
Björn Bidar <bjorn.bidar@thaodan.de> writes:
> Would it be possible to also handle image data in the function or
> refactor the org-link-preview-file function in a way that the geometry
> handling is done in a helper function which can be reused by other
> handlers.
There is such function: `org-display-inline-image--width'.
We may consider exposing it as public function.
> The link element passed towards the handler didn't contain the
> description e.g. in this case file:https://stable.melpa.org/packages/rpm-spec-mode-badge.svg.
This is expected. See https://orgmode.org/worg/dev/org-element-api.html#org22c967a
You can access the contents by looking at buffer text between
:contents-begin and :contents-end. Either directly, or by invoking
sub-parser on the text.
--
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>
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2024-12-14 7:04 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <6755f138.0c0a0220.40388.51fbSMTPIN_ADDED_BROKEN@mx.google.com>
2024-12-13 5:49 ` Link preview generation with new link preview property Karthik Chikmagalur
2024-12-14 0:03 ` Björn Bidar
2024-12-14 7:04 ` Ihor Radchenko
2024-12-08 19:18 Björn Bidar
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).