Allow asset processing on medias added by editors

The main issue behind my question is that I need to optimize pictures (resize/crop etc…) added by editors in an upload directory on a current project which cannot be moved to using Page Bundles.

If this existing upload directory were to be moved underneath assets, this would allow processing of medias passed as Front Matter param, but medias added as regular markdown images would not be published. Therefor existing ![Whatever](upload/image/whatever.jpg) in my markdown would not work.

This makes it impossible to successfully manage site wide image optimization without search/replace image mention of existing files and demanding editors from now on to uses a short-code to add images.

Shall my concern be heard and wished to be addressed, here is a solution which looks simple but may very well not be… :

Hugo Pipes’ .Get would look inside both assetDir and staticDir while maintaining the strict publish rule only on files within assetDir. Files inside static would still be published as is alongside their “processed” versions.
A solution to deal with duplicates could involve warning during build or config toggle to able/disable staticDir/assetDir merge etc…)

I know a simple symlink could do it for one project, but I was more hoping for a Hugo implemented solution.

1 Like

My original implementation looked in all of /assets /content and /static. But then I started to think about all of it. Mostly partial server builds. So anyone taking on this task must complete that thought process.

1 Like