Problems adding image caption
I would like the plugin to also parse the caption of an image, like when using org-html-export-as-html, so that the relative path for the image folder is ../images for the source as well as for the output files. Now when I use the syntax [[../images/file.png]] and export the function org-html-export-as-html then img src tag contains the correct path:
<img src="../images/meditate.png" alt="meditate.png" />
However when building with Nikola then for some reason the ../ in the image path is removed:
<img src="images/meditate.png" alt="nil">
Now from the first answer here I tried to add the ../ back using:
(defun my-custom-figsource (contents backend info)
(when (eq backend 'html)
(replace-regexp-in-string "src=\""
"src=\"../" contents)))
(add-to-list 'org-export-filter-final-output-functions #'my-custom-figsource)
(this just replaces the the src=" with src="../). However now when building with Nikola I get a double ../../ in the image path.
I guess my question is, why the ../ is removed when building with Nikola?
If this would work, then I guess also the file and img-url links types here could just be removed, and the info replaced with the correct info, i.e. just use a relative path instead of the nikola style path [[/images/file.png]] which gets resolved as an absolute path. I am happy to take care of that, as soon as I find out why the ../ is getting removed by the Nikola build.
Okay, I am still wondering how it all works exactly, but I was able to get what I want by adding the following lines to init.el:
(defun my-custom-figsource (contents backend info)
(when (eq backend 'html)
(replace-regexp-in-string "src=\"/"
"src=\"" contents)))
(add-to-list 'org-export-filter-final-output-functions #'my-custom-figsource)
So now I just use a relative link incl. caption like this:
#+CAPTION: caption text
#+NAME: fig_name
[[../images/file.png]]
and now the image paths in the img src tags in both the blog its index.html and the post its index.html are correct.
Actually with this solution I am not really sure what useful feature the img-url and file link types add.
Maybe I should replace them and the instructions with this solution?