Skip to content
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

Question: Post image from Hugo page resources #293

Closed
davidsneighbour opened this issue Mar 20, 2022 · 5 comments
Closed

Question: Post image from Hugo page resources #293

davidsneighbour opened this issue Mar 20, 2022 · 5 comments
Projects

Comments

@davidsneighbour
Copy link

davidsneighbour commented Mar 20, 2022

I am using Frontmatter in connection with Hugo and wonder if it's possible to somehow use images as article image on the dashboard when they are defined in the resources section of the frontmatter.

frontmatter sample

---
...
resources:
  - title: "caption"
    id: "id1"
    src: "header.jpg"
  - title: "caption2"
    id: "id2"
    src: "header2.jpg"
---

I would expect the solution to show the image of the first resource (header.jpg). This can of course be "hacked" by adding an additional frontmatter item with the header image, but that would not be used in the theme at all and only for Frontmatter to look nice.

Page Resources is a fairly integral piece of Hugos page bundle system. This would have to check if the first item is an actual image though, because other media types could take that place.

@estruyf
Copy link
Owner

estruyf commented Mar 20, 2022

Hi @davidsneighbour did you define a block field for the resources metadata?

By default FM does not show or use resources, as you need to tell it what to render/use. That said, the block field allows you to re-use predefined fields to create list data. This would allow you to create the appropriate data for your theme.

@davidsneighbour
Copy link
Author

I tried that but am still not able to get to what I want. The block field works nicely, but what I want to achieve is, that the article image, which is defined in the block is shown on the dashboard, not the website. Currently it shows the markdown symbol:

20220327-18:22:34-Selection-001

I will go through the field docs again and see what I misunderstand. Basically, isPreviewImage for my block would be nice ;)

The config in question is here.

I'll add to this issue when I am further.

@estruyf
Copy link
Owner

estruyf commented Mar 28, 2022

The preview image for block fields is not yet supported, but I'll push a new update in a couple of minutes to have this supported as well.

In your case, what you have to do is update the resources field group as follows:

{
  "id": "resources",
  "labelField": "src",
  "fields": [
    {
      "title": "Path/Filename",
      "name": "src",
      "type": "image",
      "isPreviewImage": true
    },
    {
      "title": "Title",
      "name": "title",
      "type": "string",
      "single": true
    },
    {
      "title": "Name (Identifier)",
      "name": "name",
      "type": "string",
      "single": true
    }
  ]
}

Changed the src field to type image and set it as the preview image.

@estruyf
Copy link
Owner

estruyf commented Mar 28, 2022

New beta version is available with this enhancement.

@estruyf estruyf added this to To do in v7.1.0 via automation Mar 28, 2022
@estruyf estruyf moved this from To do to In progress in v7.1.0 Mar 28, 2022
@davidsneighbour
Copy link
Author

Perfectly working :) Thank you!

v7.1.0 automation moved this from In progress to Done Apr 3, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
No open projects
Development

No branches or pull requests

2 participants