# Image processing module

**URL:** <https://discourse.gohugo.io/t/image-processing-module/39838>\
**Category:** tips & tricks\
**Tags:** modules\
**Created:** [August 5, 2022, 6:44am UTC](https://discourse.gohugo.io/t/image-processing-module/39838 "2022-08-05T06:44:33Z")\
**Posts on this page:** 14\
**Page:** 1

<div class="post-metadata">

**Author:** ![powerfulwebdesign](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/powerfulwebdesign/32/14227_2.png) [@powerfulwebdesign](https://discourse.gohugo.io/u/powerfulwebdesign)\
**Post date:** [August 5, 2022, 6:44am UTC](https://discourse.gohugo.io/t/image-processing-module/39838/1 "2022-08-05T06:44:33Z")

</div>

Hi everyone.

I have just made a module which creates responsive images. Its actually in its 3rd iteration, but v1 for this repository.

> **[GitHub - future-wd/hugo-responsive-images](https://github.com/future-wd/hugo-responsive-images)**
>
> Contribute to future-wd/hugo-responsive-images development by creating an account on GitHub.

It supports the following:

- minimal config
- minimal inline code (unless you want to override configurations)
- outputs original format image plus webp (can be configured)
- choose from pixel density (1x,2x) or variable with (e.g. 400px, 800px, 1200px) output
- choose aspect ratio of output image (so multiple images line up properly)
- integrates with lazysizes, so you don’t have to set the sizes property (this can be turned off)
- also generates figures
- has a shortcode for images/figures
- has a render hook which can be turned on/off via config or the pages front matter

More features to come soon including

- lquip blur up placeholder
- external image support
- noscript support (required js and css so i’ve left it out for now to keep it simple)

PR’s and feedback welcome

---

<div class="post-metadata">

**Author:** ![lkhrs](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/lkhrs/32/22287_2.png) [@lkhrs](https://discourse.gohugo.io/u/lkhrs)\
**Post date:** [August 5, 2022, 10:27pm UTC](https://discourse.gohugo.io/t/image-processing-module/39838/2 "2022-08-05T22:27:28Z")

</div>

Looks great! Love that you included the option in the partial to selectively disable lazy-loading - which is necessary for above-the-fold images.

I have two suggestions while browsing through the code:

1. The use of `<h4>`s in the `<figcaption>` will break [heading rank](https://www.w3.org/WAI/tutorials/page-structure/headings/#heading-ranks), which is not good for accessibility
2. Instead of falling back to the page title for alt descriptions on images, I think a [warning](https://gohugo.io/functions/errorf/) should be thrown instead (personally, I’d throw an error and terminate build, but that might be too strict). Accurate image descriptions are important for screenreader users and those with slow connections

---

<div class="post-metadata">

**Author:** ![Gerriet](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/gerriet/32/19164_2.png) [@Gerriet](https://discourse.gohugo.io/u/Gerriet)\
**Post date:** [August 7, 2022, 10:10pm UTC](https://discourse.gohugo.io/t/image-processing-module/39838/3 "2022-08-07T22:10:36Z")

</div>

Hi there ;D  
Wow, thats great module, thanks for share ;D

---

<div class="post-metadata">

**Author:** ![neilbaldwin](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/neilbaldwin/32/17382_2.png) [@neilbaldwin](https://discourse.gohugo.io/u/neilbaldwin)\
**Post date:** [August 11, 2022, 1:28pm UTC](https://discourse.gohugo.io/t/image-processing-module/39838/4 "2022-08-11T13:28:17Z")

</div>

Great work!

---

<div class="post-metadata">

**Author:** ![powerfulwebdesign](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/powerfulwebdesign/32/14227_2.png) [@powerfulwebdesign](https://discourse.gohugo.io/u/powerfulwebdesign)\
**Post date:** [August 18, 2022, 8:05am UTC](https://discourse.gohugo.io/t/image-processing-module/39838/5 "2022-08-18T08:05:17Z")

</div>

Thanks for your feedback.

I have updated the module so an error is thrown if there is no alt text. It can be suppressed.

In regards to figure caption heading level. Do you think I should include a config e…g

```auto
(dict
"h" "4" )

```

or shortcode

```auto
{{< figure src=image.jpg alt="Alt text" h=4 >}}
```

---

<div class="post-metadata">

**Author:** ![powerfulwebdesign](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/powerfulwebdesign/32/14227_2.png) [@powerfulwebdesign](https://discourse.gohugo.io/u/powerfulwebdesign)\
**Post date:** [August 18, 2022, 8:06am UTC](https://discourse.gohugo.io/t/image-processing-module/39838/6 "2022-08-18T08:06:31Z")

</div>

Thanks to everyone who has had a look, a lot has gone into this module.

Issue requests, pull request and general feedback on the chat tab on the github page is welcome.

---

<div class="post-metadata">

**Author:** ![powerfulwebdesign](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/powerfulwebdesign/32/14227_2.png) [@powerfulwebdesign](https://discourse.gohugo.io/u/powerfulwebdesign)\
**Post date:** [August 18, 2022, 8:44am UTC](https://discourse.gohugo.io/t/image-processing-module/39838/7 "2022-08-18T08:44:20Z")

</div>

If anyone uses netlify images or another provider, I would appreciate your help testing the external image processing api feature which I am adding to the responsive images module.

---

<div class="post-metadata">

**Author:** ![powerfulwebdesign](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/powerfulwebdesign/32/14227_2.png) [@powerfulwebdesign](https://discourse.gohugo.io/u/powerfulwebdesign)\
**Post date:** [August 25, 2022, 8:33pm UTC](https://discourse.gohugo.io/t/image-processing-module/39838/8 "2022-08-25T20:33:55Z")

</div>

@lkhrs I have implemented those 2 suggestions, thanks for the feedback.

You will see it on the current readme

---

<div class="post-metadata">

**Author:** ![MarcMartin](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/marcmartin/32/15735_2.png) [@MarcMartin](https://discourse.gohugo.io/u/MarcMartin)\
**Post date:** [September 20, 2022, 12:01pm UTC](https://discourse.gohugo.io/t/image-processing-module/39838/9 "2022-09-20T12:01:51Z")

</div>

Module looks great. Tried implementing it on my site, and I get the following build error.`Error: Error building site: "C:\Users\marcl\Documents\Web Dev\Foothills Overhead Doors\content\_index.html:11:5": failed to render shortcode "image": failed to process shortcode: "C:\Users\marcl\AppData\Local\Temp\hugo_cache\modules\filecache\modules\pkg\mod\github.com\future-wd\hugo-responsive-images@v1.1.10\layouts\shortcodes\image.html:20:4": execute of template failed: template: shortcodes/image.html:20:4: executing "shortcodes/image.html" at <partial "hri/private/shortcode-template" $params>: error calling partial: "C:\Users\marcl\AppData\Local\Temp\hugo_cache\modules\filecache\modules\pkg\mod\github.com\future-wd\hugo-responsive-images@v1.1.10\layouts\partials\hri\private\shortcode-template.html:17:5": execute of template failed: template: partials/hri/private/shortcode-template.html:17:5: executing "partials/hri/private/shortcode-template.html" at <partial (print .name) .>: error calling partial: "C:\Users\marcl\AppData\Local\Temp\hugo_cache\modules\filecache\modules\pkg\mod\github.com\future-wd\hugo-responsive-images@v1.1.10\layouts\partials\image.html:19:15": execute of template failed: template: partials/image.html:19:15: executing "partials/image.html" at <partial "hri/private/params.html" .>: error calling partial: "C:\Users\marcl\AppData\Local\Temp\hugo_cache\modules\filecache\modules\pkg\mod\github.com\future-wd\hugo-responsive-images@v1.1.10\layouts\partials\hri\private\params.html:37:22": execute of template failed: template: partials/hri/private/params.html:37:22: executing "partials/hri/private/params.html" at <$img.Params>: nil pointer evaluating resource.Resource.Params`

I’m using global assets folder, and set it all up according to the github readme. Wondering if you have any ideas?

Heres the repository if you need it [Repo](https://github.com/marcmartin-prog/foothills)

---

<div class="post-metadata">

**Author:** ![powerfulwebdesign](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/powerfulwebdesign/32/14227_2.png) [@powerfulwebdesign](https://discourse.gohugo.io/u/powerfulwebdesign)\
**Post date:** [September 21, 2022, 5:51am UTC](https://discourse.gohugo.io/t/image-processing-module/39838/10 "2022-09-21T05:51:25Z")

</div>

Hi @MarcMartin,

I had a look at your code and sent you a PR.

I was actually hoping you found a bug so I could fix it as It’s hard to think of all use cases.

The issue was that there was no type=global property for the shortcode.

Alternatively if all of your images are global, you can specity type: global in the config (its the last item).

You actually don’t need any of the hugo imaging/hugo-responsive-images config that you have, as it seems its all default. The defaults have already been included in the module. However this will prevent any “breaking changes” if the defaults were to change over time.

If you need any futher help just let me know. Maybe the readme could be better? You can always submit a PR or log it on github.

---

<div class="post-metadata">

**Author:** ![powerfulwebdesign](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/powerfulwebdesign/32/14227_2.png) [@powerfulwebdesign](https://discourse.gohugo.io/u/powerfulwebdesign)\
**Post date:** [September 21, 2022, 5:54am UTC](https://discourse.gohugo.io/t/image-processing-module/39838/11 "2022-09-21T05:54:13Z")

</div>

And a side note, you will probably have to go in and add widths=600,1000,200 or whatever you want as the defaults don’t work too well for images that are full widths on desktops.

---

<div class="post-metadata">

**Author:** ![MarcMartin](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/marcmartin/32/15735_2.png) [@MarcMartin](https://discourse.gohugo.io/u/MarcMartin)\
**Post date:** [September 21, 2022, 11:33am UTC](https://discourse.gohugo.io/t/image-processing-module/39838/12 "2022-09-21T11:33:09Z")

</div>

Great. Thanks so much! I may try to add a PR to the readme. I overlooked the small mention of type.

---

<div class="post-metadata">

**Author:** ![powerfulwebdesign](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/powerfulwebdesign/32/14227_2.png) [@powerfulwebdesign](https://discourse.gohugo.io/u/powerfulwebdesign)\
**Post date:** [September 21, 2022, 5:33pm UTC](https://discourse.gohugo.io/t/image-processing-module/39838/13 "2022-09-21T17:33:10Z")

</div>

Thanks. By the way Type isnt required for page resources as its the default

---

<div class="post-metadata">

**Author:** ![system](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/system/32/1_2.png) [@system](https://discourse.gohugo.io/u/system)\
**Post date:** [September 23, 2022, 5:33pm UTC](https://discourse.gohugo.io/t/image-processing-module/39838/14 "2022-09-23T17:33:37Z")

</div>

Closed on September 23, 2022, 5:33pm UTC

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.
