Fork me on GitHub
#emacs
<
2022-10-16
>
teodorlu06:10:54

Hi 🙂 Org-mode help wanted. TL;DR: I have an image on a an url like this: - no jpg extension. Is it possible to hotlink to this image from an org-mode document? When I try [[, I get an a href, but I want an img src in my HTML. Any ideas? Are there org-native solutions to this that I'm not aware of? More details in thread. Thanks!

teodorlu07:10:42

Full set of details: Normally, I just link to images like this:

[[./cat.jpg]]
But I want to hotlink to this image:
(rich explaining simple vs easy, first attached image) But when I do this:
[[
Org-mode naturally makes a link for me, and my resulting HTML has an <a href=".." ..., which is not what I wanted (second attached image). I'm aware that I can hand code the HTML like this:
#+BEGIN_EXPORT html
<img src=""></img>
#+END_EXPORT
but I'd like to avoid that. It's tedious to write, and doesn't work when I export to other formats.

blak3mill3r11:10:54

one way to achieve this would be to write elisp that does exactly what your tedious, hand-coded HTML solution does...

blak3mill3r11:10:59

this is probably the easiest way

blak3mill3r11:10:53

writing an interactive elisp function would be more readable than a saved macro

blak3mill3r11:10:21

but if you just want a solution in minimal time, saving a macro is likely the most efficient way to automate some repetitive action that you do yourself (once you get used to it)

blak3mill3r11:10:39

I will add that I am an org-mode noob, and this recommendation isn't specialized to org-mode ... I suspect it will work fine, but I'm not certain

teodorlu12:10:48

Huh, good point. I could just write myself a function. I'd still have to track the full export block in git, though.

teodorlu12:10:46

Thank you! 💯

👍 1
blak3mill3r12:10:34

Yeah, if you don't want to track the full export block in git, you'll need to change (or, fix?) the code in org

👍 1
Benjamin08:10:06

don't know if you figured it out but I see something in ox-html :html-inline-images

Benjamin08:10:39

also the docstring of org-export-inline-image-p

teodorlu09:10:43

Lack of image preview isn't really a big problem for me. It's more that I'd like to write normal org-mode syntax, not random html blocks =/

teodorlu09:10:24

That's what I meant with "org-native" - but I realize that's kind of vague....

Benjamin09:10:01

I'm certain you can make it export <img> tags with normal org links

teodorlu09:10:09

I'd love to see a counter example to the thing I posted in the OP :) Basically - I have an image that's missing its jpg extension, and it becomes a link rather than an image in html.

👀 1