Have tested 0.32-DEV on my site with no changes, build runs fine, no obvious issues in the build output. Resources seem to work fine too, tested image resizing with no issues, multiple resources for a single page looks fine too.
This was done on both Linux (Arch) and Windows 10 (will latest updates applied)
Awesome work! Can’t wait for the release!
I can run more specific tests of this if needed
(Not sure how I feel about .Resources.GetByPrefix, as most places drop the Get, so .Resources.ByPrefix, just thought i’d raise it)
Yea, naming is hard. I thought long and hard about that one too, but I have used in other placed to mark the distinction between one (Get) and potentially many.
I really appreciate you testing it on OSes I currently do not run (I have a bigger SSD for my Mac in order so I can have more virtual OSes on disk at the same time; then I can maybe improve my own testing).
I’ve just tested it on my site with MacOS High Sierra, and everything seems to work as it were before.
I’ll try the new resource and image manipulation once I have more time and I’ll come back to you.
By the way, I was wondering if it were possible to get the resources from a specific folder ?
This is, I guess, a common use for this in the list templates: List all pages with some kind of thumbnail as an illustration. You will need to come up with some kind of naming standard for this and use .Resources.GetByPrefix "main-image" or something, or pick the first or whatever.
You would currently need to use .Resources.ByType "image" and filter them with some other means (where?). This is possibly related to the GetByPrefix discussion above (which with .GetByPrefix "something" in your example will return that one photo), but I will not add any more API to this until I see how people use this.
@bep So I went the extra mile to compile Hugo from source on Ubuntu Gnome 16.04. (had to remove the Hugo snap, update Go etc)
My 4 Hugo projects are served as they used to, so I haven’t encountered any breaking bugs with: Hugo Static Site Generator v0.32-DEV linux/amd64 BuildDate: 2017-12-29T13:31:34+02:00
I’ll give you further feedback on the new features later today.
Good to hear. I have tested a fair amount of sites myself, so if nothing substantial pops up I’m planning on a New Year’s Eve release … I notice my main commit on all of this has a commit date back in July (plenty rebase going on there), so I’ll have to get this out before 2018 …
And I’m very happy because now I can move away from Hugo shortcodes to pure markdown syntax images and be able to wrap them in whatever html I need with something like:
{{ range .Resources.ByType "image" }}
<figure><img src="{{ .Permalink }}"></figure>
{{ end }}
It’s really cool that a simple markdown image within a content file like ![](after-as-before-1.jpg) is now recognized and served by Hugo without resorting to hacks.
So for this feature alone I am very happy! And thank you @bep
Hugo 0.32 makes things much easier. Now even a non dev can easily update a Hugo site with an editor like Atom.
PS.1. I haven’t tested Image Processing yet and I have to go now. But I plan to check this out tomorrow and try to see how I can construct an <img> with the srcset attribute using the new features.
PS.2 Your hugo-test site was really indispensable for me to understand how .Resources work. Make sure to mention it when Hugo 0.32 is released.
Resizing 12 images that were 1280px wide, was done in the blink of an eye!
No need to waste anymore time fiddling with external scripts (image magick etc).
No need to set front matter parameters for the thumbnails of list pages.
No need to copy paste images into the appropriate folders.
I do have a question though.
Hugo does not regenerate already processed images under /resources/_gen/. Only if hugo --gc is used will Hugo waste time regenerating. Correct?
Correct. Resizing 12 images is pretty fast; doing this for thousands will still feel slow, so I have spent a considerable amount of brain power to cache as intelligently as possible.
No, the --gc will only remove unused images. It is a cleaning tool. If you, for some reason, want to regenerate, you will need to delete the directory yourself.
@bep I just found out that to call a bundled content page’s .Title from within the .Resourcesrange I had to call it like we do from within a shortcode :
{{ range .Resources.ByType "image" }}
<figure><img src="{{ .Permalink }}" alt="{{ with $.Page.Params.title }}{{ . }}{{ end }}"></figure>
{{ end }}
Calling the title with alt="{{ .Title }}" fails with the following console error:
ERROR 2017/12/30 20:21:01 in .Render: Failed to execute template...etc.
If you think it will be helpful to others, you can include the above code block as an example in the Docs.