Hello everyone,
I have been using the following extension to more easily manage the various image size on my Middleman site: middleman-simple-thumbnailer. the principle is that this extension extends the image template helper and provide a “resize_to” option. New resized images are then generated alongside the originals in the source/images folder, ready to be deployed. for lazy persons like me, this is very convenient, because I do not have then to open my image manipulation application to be able to serve correctly sized images.
This extension was working great even in Middleman 4 (with the correct PR #11), but failed on Middleman 4.1.
After a little bit debugging, I was able to determine that the new “parallel” mode was breaking the extension, and that everything was working ok withe the “–no-parallel” option.
I finally found a way to make it work (PR #12) by using what I consider an hack. I am using a external temporary files to share state between the middleman build processes.
The core of the problem comes from the fact that this extension generates files during the emission phase. To avoid these files to being deleted in the “clean” phase of the build, the files are generated in the “after_build” method of the extension.
Personally I have the feeling that this extension should register the new files in the sitemap. But the sitemap is established by middleman (and by delegation by the extensions) before the file emission phase, whereas this extension will have its file list after the file emission. There is a mismatch here.
For inspiration, I have tried to see if another extension is operating with the same principle. I have looked in the “official” Middleman Extension Directory (https://directory.middlemanapp.com), but I could not fond another one…
So here are my questions:
- Is this extension working principle is sound?
- What do you think about the workaround I found to make it work with middleman 4.1?
- Do any of you have some recommendation to make it more safe, fast, less “hacky”…?
- Is there a way to manipulate the sitemap during or after the build file emission phase?
- if not, could this be a feature request for a next middleman version?
- In any case, I found the middleman documentation somewhat lacking on the subject (the exact description of the build lifecycle, with the interaction with the extensions), but I do not feel really knowledgeable enough to be able to produce a solid contribution. Should I open a Github issue for this?
Thank you in advance for your responses!
regards,
ymh