-
Notifications
You must be signed in to change notification settings - Fork 111
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use page resources #46
base: master
Are you sure you want to change the base?
Conversation
Hi @EmielH Thanks so much for your contribution and offer to help maintain the project; I really appreciate it. I wasn't aware of Hugo's new Page Resources feature (yes it's been that long since I have worked on this project), but having briefly read about it, I can see it greatly simplifies things for hugo-easy-gallery and I'm keen to adopt it. This is a fairly big change that affects the way hugo-easy-gallery works, so we need to check whether it breaks any existing functionality, and we need to make sure that the readme docs are updated. It looks like the proposed change removes or changes some existing features:
Some of these features are worth keeping; some are not; some are possible to re-implement using page resources; some are not. For now, I suggest the best thing to do is keep all the old code, and use the page resources method only if no e.g.
I can't remember if the The Readme docs need to be updated with details of:
Some other features that may be worth implementing:
Thanks again, this is a great contribution :-) Li-Wen |
Hi @liwenyip, thank you for your very extensive review. It would appear that, in the process of making the shortcode work with page resources, I broke everything else... 😓 I was quite happy with the simplification of hugo-easy-gallery when using page resources, but there should of course be backwards compatibility, at least at first.
👍 I will make the necessary changes and commit these to the branch. |
Hey @EmielH No worries, and please don't take my comments as criticism - it was more me thinking aloud whilst trying to remember how my own code works (I haven't looked at this for well over a year) and trying to make a list of things that we should try to re-implement using page resources :-) Thanks again, |
Hi @liwenyip, no problem, I wasn't offended! I agree that a lot of additional functionality could be added using page resources. 👍 I just pushed a commit that restores the original functionality. Two remarks: If you want to use page resources, the shortcode should be included as a self-closing tag:
I haven't updated the readme yet. Unfortunately, I do not have test cases yet to check whether the original functionality still works. I only tested the page resources part for now. |
Does this need any more testing? I've just started integrating easy-gallery into my site and it looks like there's a lot of new stuff in Hugo (including image processing that could be used to dynamically generate thumbnails) that could go in once this plugin is upgraded further. |
@ex-nerd It does! I tried to incorporate the new stuff you mention into this PR. Possibly, more things have changed since then and this plugin could be improved even further; I haven't looked at the code anymore since my last commit in April. |
{{- else }} | ||
<!-- Generate figures for all page resources of type image. --> | ||
{{- range $.Page.Resources.ByType "image" -}} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In order to more closely reproduce the default behaviour, I've added
{{- $caption := .Title | replaceRE "\\..*" "" | humanize }}<!-- humanized filename without extension -->
here, so that I could use it in both line 50 (changing alt="{{.Title}}"
to alt="{{ $caption }}"
and in line 54, using <p>{{ $caption }}</p>
instead of <p>{{ . }}</p>
.
Other than that, its working fine. Thanks!!
Hi! Thanks a lot for this shortcode, it's very useful!
I did a complete overhaul to make use of Hugo Page Resources which makes ranging over files to make a gallery a lot easier.
The gallery shortcode can now also create thumbnails on the fly, with a configurable thumbnail size, for example:
{{< gallery dir="/img/your-directory-of-images/" thumbnail-size="150x150" />}}
. The parameter for thumbnail size is not mandatory: the shortcode defaults to 300x300.I'm already using this updated version on my site, except for the configurable thumbnail size, which I added today.
I would also be willing to help maintain this project. Let me know if you would like my help!