emacs-love / weblorg

Static Site Generator for Emacs
https://emacs.love/weblorg
GNU General Public License v3.0
279 stars 21 forks source link

[Question] Image Support #49

Closed AblatedSprocket closed 2 years ago

AblatedSprocket commented 3 years ago

Is there support for parsing on Org link to an image file when exporting? For example, parsing the link as an tag (or something) in the HTML output?

clarete commented 3 years ago

hi @AblatedSprocket thanks for taking the time to open this issue with your question.

Do you refer to inserting an Org-Mode link to an image file and get that link to be translated to an <img> tag? If so, you currently have to link it directly to the file with a regular org-mode link

[[/path/the/image/file.png]]

If you're looking into using weblorg's routing system, unfortunately, url_for currently only generates a tags. e.g.:

[[url_for:static,file=image.png][an image]]

I think it'd be great to find a way to tell url_for to generate an img tag instead of a regular link. Let me know if you have any suggestions. I'll see if I can come up with something too in the meantime 😄

AblatedSprocket commented 3 years ago

There's another issue open for this, but I think my ideal use case would be using plain old org syntaxes and weblorg would override the exporter. That sounds hard though.

Using url_for would work ok for me as well and sounds easier, I'll look and see if I can think of something.

AblatedSprocket commented 3 years ago

What if we just add another definition in org-link-set-parameters:

(org-link-set-parameters
     "img"
     :export (lambda(path desc _backend)
               (format "<img href=\"%s\" />" (weblorg--url-for path site)))
clarete commented 3 years ago

Hi @AblatedSprocket 👋🏾 this looks pretty good to me. What do you think about calling it url_for_img? you can register it in weblorg--route-install-template-filters 🙇🏾 do you think you'd be interested in trying to put another lil PR for this? 😄

AblatedSprocket commented 3 years ago

You know, I just might

clarete commented 3 years ago

Just merged #53, thank you @AblatedSprocket for another contribution to weblorg 😄 thank you for taking the time 🙇🏾

AblatedSprocket commented 3 years ago

Thanks for creating such a great library!

clarete commented 2 years ago

added docs for this the commit https://github.com/emacs-love/weblorg/commit/7ccfc443d1d4ded4cde0b6b6e9ebd184601a94d6