HugoBlox / hugo-blox-builder

🚨 GROW YOUR AUDIENCE WITH HUGOBLOX! 🚀 HugoBlox is an easy, fast no-code website builder for researchers, entrepreneurs, data scientists, and developers. Build stunning sites in minutes. 适合研究人员、企业家、数据科学家和开发者的简单快速无代码网站构建器。用拖放功能、可定制模板和内置SEO工具快速创建精美网站!
https://hugoblox.com/templates/
MIT License
8.12k stars 2.89k forks source link

Cover Image in Book Layout #2946

Closed Agos95 closed 1 year ago

Agos95 commented 1 year ago

Preliminary Checks

Description

In Wowchemy v5.7.0 we introduced the get_featured_image funtion to retrieve the feature image in a more flexible way.

However, this causes some problems in hte Book layout, such as in the Online Course Template. In fact, if we update to the latest Wowchemy version (main branch), we get:

book_cover_image

This is due to the fact that get_featured_image finds the attachment featured.jpg in the folder, and automatically sets it as a cover image (change introduced in 18ac0b4). Instead, the logic behind the template is to include the image using {{<figure>}} shortcode, and use featured.jpg just for the course page.

If we rename featured.jpg to something else, we loose the image in the course page.

Proposed Solution

I am already working on a PR to fix this issue. My idea is to include in the Front Matter of a book page something like

---
cover: true|false
---

(with true as default), and to include the cover image only if this parameter is true.

Reproduction Link

https://github.com/Agos95/wowchemy-hugo-themes/tree/update-starters/starters/course

Steps to Reproduce

  1. Clone Online Course Template
  2. Update Wowchemy module in go.mod to the latest version (main branch)
  3. Go to one of the courses, which use the book layout

Expected Result

Cover image should not appear

Actual Result

Cover image appears automatically since get_featured_image finds the attachment featured.jpg in the folder

What Hugo Module versions does your site use?

module github.com/wowchemy/starter-hugo-online-course

go 1.15

require ( github.com/wowchemy/wowchemy-hugo-themes/modules/wowchemy-plugin-netlify v1.0.0 // indirect github.com/wowchemy/wowchemy-hugo-themes/modules/wowchemy-plugin-netlify-cms v1.0.0 // indirect github.com/wowchemy/wowchemy-hugo-themes/modules/wowchemy/v5 v5.7.1-0.20230501161443-2d67669ce769 // indirect )

What operating system(s) are you seeing the problem on?

Linux

What browser(s) are you seeing the problem on?

Firefox

Which Wowchemy template are you using?

Online Course

What version of Hugo are you using?

Hugo extended 0.111.3

gcushen commented 1 year ago

I'm unsure if I understand what the problem is. If the image is now displayed twice in the Course Starter Template, why not just remove the second image (the {{<figure>}}) from the template's Markdown file?

Agos95 commented 1 year ago

In Book layout, the cover image is fitted to 1800x310 px

https://github.com/wowchemy/wowchemy-hugo-themes/blob/2d67669ce7694d4b2f632994660ca7aeff27f0db/modules/wowchemy/layouts/partials/book_layout.html#L40

so it is cropped and resized.

So, I suggest one of the following:

  1. add the Parameter preview_only, as for page cover images
  2. Align the code for the Book cover image https://github.com/wowchemy/wowchemy-hugo-themes/blob/2d67669ce7694d4b2f632994660ca7aeff27f0db/modules/wowchemy/layouts/partials/book_layout.html#L35-L46

    to the one of Pages cover/banner images https://github.com/wowchemy/wowchemy-hugo-themes/blob/2d67669ce7694d4b2f632994660ca7aeff27f0db/modules/wowchemy/layouts/partials/page_header.html#L18-L60

github-actions[bot] commented 1 year ago

This issue is stale because it has not had any recent activity. The resources of the project maintainers are limited, and so we are asking for your help.

If this is a bug and you can still reproduce this error on the main branch, consider contributing a Pull Request with a fix.

If this is a feature request, and you feel that it is still relevant and valuable, consider contributing a Pull Request for review.

This issue will automatically close soon if no further activity occurs. Thank you for your contributions.