about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--ennum.el24
1 files changed, 15 insertions, 9 deletions
diff --git a/ennum.el b/ennum.el
index 1526e48..6314a5c 100644
--- a/ennum.el
+++ b/ennum.el
@@ -673,7 +673,8 @@ result as a string."
          :locale-alist :other-files-directory
          :pdf-width :pdf-height :store
          :tag-directory :image-thumbnail-width
-         :required-metadata :other-items)
+         :required-metadata :generated-image-paths
+         :other-items)
      (plist-get (org-combine-plists
                  (list :atom-feed-number-of-posts 12
                        :atom-feed-file "blog.atom"
@@ -757,14 +758,21 @@ recognized as a directory, it should end in a slash. See
 (defun ennum--filter-map (function sequence)
   (seq-filter 'identity (seq-map function sequence)))
 
+(defun ennum--find-image (path)
+  "Find store item for image with PATH."
+  (or (seq-find 'file-exists-p
+                (seq-map (apply-partially 'expand-file-name
+                                          path)
+                         (ennum-setting :generated-image-paths)))
+      (ennum-intern (ennum--file-join (ennum-setting :images-directory)
+                                      path))))
+
 (defun ennum-publish-link (link)
   (pcase (ennum-link-type link)
     ('image
      (seq-map (lambda (width)
-                (ennum-publish-image
-                 (ennum-intern (ennum--file-join (ennum-setting :images-directory)
-                                                 (ennum-link-path link)))
-                 width))
+                (ennum-publish-image (ennum--find-image (ennum-link-path link))
+                                     width))
               (list (ennum-setting :image-width)
                     (ennum-setting :image-link-width))))
     ((or 'pdf 'static)
@@ -850,10 +858,8 @@ as keys. Keys are compared using `equal'."
                (ennum-many-to-many-group-by 'ennum-post-tags posts))
               ;; Publish thumbnails
               (seq-map (lambda (image)
-                         (ennum-publish-image
-                          (ennum-intern (ennum--file-join (ennum-setting :images-directory)
-                                                          image))
-                          (ennum-setting :image-thumbnail-width)))
+                         (ennum-publish-image (ennum--find-image image)
+                                              (ennum-setting :image-thumbnail-width)))
                        (ennum--filter-map 'ennum-post-thumbnail posts))
               ;; Publish other files
               (seq-map (apply-partially 'ennum-publish-generic other-files-directory)