Hi,

By default, ox-html inlines most image links (such as png and jpg). However, this is currently not the case for webp.

Webp is a image format introduced in 2010 by Google, which now has widespread adoption in mainstream browsers. I personally would like to use it because it has much better compression levels than the older alternatives. For more information on support levels, this site has a synopsis: https://caniuse.com/webp

Since it has widespread adoption and support, I would like to propose adding it to the default filetypes ox-html inlines as images. A patch is provided below to do this. Let me know if you have any thoughts or suggestions.

Thanks for all your hard work,
-Jay

>From e7385370a9a023a68f123374793bc8d706d5580c Mon Sep 17 00:00:00 2001
From: Jay Kamat <jaygka...@gmail.com>
Date: Mon, 8 Mar 2021 16:55:37 -0800
Subject: [PATCH] ox-html: Add webp as an inline image format

* lisp/ox-html.el (org-html-inline-image-rules): Add webp as an inline
  image format

Webp is an image format introduced in 2010, which now has widespread
support in browsers. ox-html can inline webp images identically to how
it does already for other image formats.

Signed-off-by: Jay Kamat <jaygka...@gmail.com>
---
 lisp/ox-html.el | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/lisp/ox-html.el b/lisp/ox-html.el
index 11757bb35..3fa5ef864 100644
--- a/lisp/ox-html.el
+++ b/lisp/ox-html.el
@@ -848,9 +848,9 @@ link to the image."
   :type 'boolean)
 
 (defcustom org-html-inline-image-rules
-  `(("file" . ,(regexp-opt '(".jpeg" ".jpg" ".png" ".gif" ".svg")))
-    ("http" . ,(regexp-opt '(".jpeg" ".jpg" ".png" ".gif" ".svg")))
-    ("https" . ,(regexp-opt '(".jpeg" ".jpg" ".png" ".gif" ".svg"))))
+  `(("file" . ,(regexp-opt '(".jpeg" ".jpg" ".png" ".gif" ".svg" ".webp")))
+    ("http" . ,(regexp-opt '(".jpeg" ".jpg" ".png" ".gif" ".svg" ".webp")))
+    ("https" . ,(regexp-opt '(".jpeg" ".jpg" ".png" ".gif" ".svg" ".webp"))))
   "Rules characterizing image files that can be inlined into HTML.
 A rule consists in an association whose key is the type of link
 to consider, and value is a regexp that will be matched against
-- 
2.20.1

Reply via email to