-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Flexible featured image name #2799
Conversation
✅ Deploy Preview for hugo-portfolio-theme canceled.
|
✅ Deploy Preview for markdown-slides canceled.
|
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.
Thanks for proposing an improvement!
- Please move all the repetitive code into a single function so that there is one place to maintain this code going forward rather than pasting the same block of code into 8 files.
- What's the purpose of adding
<!--unformattedContent-->
to the files?
If you're unfamiliar with Hugo template functions, check out: |
I should have applied the requested fixes:
Please, let me know if something more is required! |
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.
Please add the line breaks back to the end of files, otherwise it shows as a modification in GitHub and is inconsistent with the rest of the code base.
Ok, I added a blank line at the end of files. |
@Agos95 thanks for contributing an improvement 🎉 |
The partial name misspelled the word "functions" as "funcctions". This caused an error when running the latest build. The error was introduced in HugoBlox#2799.
Purpose
This allows more flexibility in the naming of the featured image for posts, and fixes #2777.
With this change, featured image is searched following this order of operations:
*featured*
in the post directory.Params.image.filename
in the post directory.Params.image.filename
in theassets/media/
directoryassets/media/
as a featured one. In this way, multiple posts can have the same featured figure without the need to upload the same image multiple times in multiple foldersassets/media/
too)This PR also #fixes the code in the different views in order to use the same logic to select the featured image.
Lastly, the change is also applied in the other files where the featured image was searched by using the hard coded
*featured*
name.Further CMS enhancement
With this PR, now the CMS can accept images with any name (thus fixing #2777). However, from the CMS you are not able to select an image which is already present in your
assets/media/
, neither you are able to upload an image to that folder, since the "image" widget is configured to look inside the post directory.Maybe it can be useful to open a new issue to address also this problem.