zola icon indicating copy to clipboard operation
zola copied to clipboard

Long shortcodes / How to best insert images from markdown

Open druskus20 opened this issue 4 months ago • 1 comments

Documentation issue

Summary

What's the best way to insert images from markdown. I would like to be able to specify: width, height. alt text, and op.

This is suggested on the docs:

{% set resized = resize_image(format="jpg", path=page.colocated_path ~ img_name, width=width, op="fit_width") %}
<img alt="{{ alt }}" src="{{ resized.url | safe }}" />

However, to the best of my knowledge this does not allow for default parameters and it becomes verbose. Creating different shortcodes for combinations of these parameters become cumbersome.

For example, we could create:

  • image
  • image_alt: alt text
  • sized_image: width, height
  • sized_image_alt: width, height and alt

But this does not scale well 4 shortcodes is already a bit too much.

druskus20 avatar Apr 18 '24 19:04 druskus20