ox-hugo
ox-hugo copied to clipboard
Copy image to static when referenced in custom front matter
Actual Behavior
Currently I'm using the following custom front matter:
#+HUGO_CUSTOM_FRONT_MATTER: :featured_image "/images/filename.jpg"
and I need to manually put the image in the /static/images/
directory.
With the actual implementation only inline images are copied from the local directory (where the .org file is placed) to the /static/images/ox-hugo
.
Expected Behavior
It should be very useful to automatically copy the image mentioned in custom front matter to /static/...
. Like inline images.
Moreover it should be very useful to add a new setting similar to org-hugo-default-static-subdirectory-for-externals
in order to specify a different destination directory and keep file organization more clean.
What do you think about?
I'll need to think this through. For now, we'll need to just manually copy the images referenced in the front-matter params.
I'd like to have a generic design so that ox-hugo doesn't need adding support for custom params like featured_image
, featured-image
, banner
, etc.
Hi, thanks for your feedback. having to manually copy only some images and some other not is quite weird. Meanwhile I will try to write a script to manually copying the images. I'd like the idea to keep all the post/page info in the same place (mainly the org files and the images). :-)
having to manually copy only some images and some other not is quite weird.
I am not denying that.
Instead of parsing for specific custom params, I am thinking of adding certain attributes above inline images, that would prevent the rendering of those images inline, and would simply copy them using the machinery we already have in place for copying the attachments.
I haven't found time to think deeper into this idea. But I am all ears to proof-of-concept or a PR.
Well, a "skip render" option on the image properties should be enough. Not bad. It requires to write at least two times the image (one on the front matter, one for the trick you're suggesting) but it's better than manually copy the image.
I am facing a similar issue but with other parameters:
:EXPORT_HUGO_CUSTOM_FRONT_MATTER: :cover '((image . "images/cover.jpg") (caption . "A cover image") (alt . "This should be the cover image"))
@finex: Did you find a feasible solution for this?
Hi, no... currently I'm still manually copying the images :-(
Alright,
I created a (suboptimal) workaround with an org special block and a CSS rule.
post.org
:EXPORT_HUGO_CUSTOM_FRONT_MATTER: :cover '((image . "/ox-hugo/cover.jpg") (caption . "some code") (alt . "code"))
...
#+begin_skipRender
[[file:images/cover.jpg]]
#+end_skipRender
This creates a markdown segment like this:
post.md
<div class="skipRender">
<div></div>
{{< figure src="/ox-hugo/unsplash-code.jpg" >}}
</div>
With some custom.css
(needs to be included into the used theme) the div will not be rendered:
.skipRender {
display: none;
}
This isn't beautiful and also redundant but it gets the job done with imho reasonable overhead.