jan-xyz / hugo-module-img-srcset

A Hugo module to modify image Markdown tags to support srcsets
The Unlicense
12 stars 1 forks source link

Alternative for when image is not a resource #1

Open Arty2 opened 4 years ago

Arty2 commented 4 years ago

This is a great example in showing how powerful Hugo can be. It'd like to suggest to add a conditional check to prevent errors when the .Destination is a fully formed external URL or miss-typed. Image processing will complain if no resource is matched.

See for related checks a partial I have been working on towards a similar purpose: https://github.com/Arty2/onion/blob/master/layouts/partials/render-image.html

Arty2 commented 4 years ago

Two minor unrelated suggestions:

  1. To remove the wrapping <p> tag. Adding the class to the <figure> tag instead makes for cleaner and more versatile code.
  2. To remove the style="width: auto;" attribute as it servers a stylistic rather than essential purpose. The image tag can be selected by .md__image img in any case.
jan-xyz commented 2 years ago

Hi @Arty2 I somehow didn't receive any notifications on this repository since I worked on this. I more or less built and forgot about it! I will have a look at your suggestions later they sound quite reasonable to me!