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

Enhancement: Ability to specify the preview image in the content type #124

Closed
estruyf opened this issue Sep 30, 2021 · 15 comments
Closed

Enhancement: Ability to specify the preview image in the content type #124

estruyf opened this issue Sep 30, 2021 · 15 comments
Labels
enhancement New feature or request
Milestone

Comments

@estruyf
Copy link
Owner

estruyf commented Sep 30, 2021

Specify which field can be used for the preview image in the content type.

The issue raised by @appieschot on Twitter: https://twitter.com/appieschot/status/1443568883248492554?s=20

@estruyf
Copy link
Owner Author

estruyf commented Sep 30, 2021

This will be supported in the upcoming release where you can specify in your content type image field that it can be used as the preview image with the isPreviewImage property.

{
  "title": "Article preview",
  "name": "custom-image",
  "type": "image",
  "isPreviewImage": true
}

@estruyf estruyf added this to the 4.1.0 milestone Sep 30, 2021
@estruyf
Copy link
Owner Author

estruyf commented Sep 30, 2021

@appieschot this is now available for testing in the https://beta.frontmatter.codes version

More information: https://beta.frontmatter.codes/docs/content-types#field-properties

@appieschot
Copy link

Awesome work 🚀, two more questions though ;-):

  • My images are stored in the /static folder (Hugo specific). When referencing you dont specify that folder and Hugo knows (https://gohugo.io/content-management/static-files/) any way we can configure that for preview's as well?
  • Even when specifying the preview URL correctly the image won't show up; it does show in the left pane as preview, but the dashboard shows an error image. Is there a place where I can look for logs?

@estruyf
Copy link
Owner Author

estruyf commented Oct 1, 2021

@appieschot did you specify the frontmatter.content.publicfolder setting with static as value?

https://frontmatter.codes/docs/settings#frontmatter.content.publicfolder

@appieschot
Copy link

Yes, the preview itself shows on the left pane (see screenshot) but throws a image not found in the dashboard.

image

Part of the settings:

 "frontMatter.taxonomy.contentTypes": [
        {
            "name": "default",
            "fields": [
                {
                    "title": "Title",
                    "name": "title",
                    "type": "string"
                },
                {
                    "title": "Publishing date",
                    "name": "date",
                    "type": "datetime"
                },
                {
                    "title": "Article preview",
                    "name": "image",
                    "type": "image",
                    "isPreviewImage": true
                },
                {
                    "title": "Is in draft",
                    "name": "draft",
                    "type": "boolean"
                },
                {
                    "title": "Categories",
                    "name": "categories",
                    "type": "categories"
                }
            ]
        }
    ],
    "frontMatter.content.pageFolders": [
        {
            "title": "post content",
            "path": "[[workspace]]/content"
        }
    ],
    "frontMatter.content.publicFolder": "static",
    "frontMatter.content.autoUpdateDate": true

@estruyf
Copy link
Owner Author

estruyf commented Oct 1, 2021

Would you be able to open the developer tools and check which URL of the image it tries to load?

@appieschot
Copy link

Learned something new; didn't know it would be that easy.

Image on the left is rendered using:
<img src="https://file%2B.vscode-resource.vscode-webview.net/c%3A/git/sbx/weblog/static/wp-content/uploads/2021/cliflowexport.webp">

The image in the dashboard is:
<img src="/wp-content/uploads/2021/cliflowexport.webp" alt="Flow missing export to logic app? Use the CLI for Microsoft 365" class="absolute inset-0 h-full w-full object-cover" loading="lazy">

Manually changing the URL only solves the problem.

@estruyf
Copy link
Owner Author

estruyf commented Oct 1, 2021

ok, know what the issue is 😀, will fix it

@appieschot
Copy link

Will have a look at the code to see if I can help out next time as well 💪

estruyf added a commit that referenced this issue Oct 1, 2021
@estruyf
Copy link
Owner Author

estruyf commented Oct 1, 2021

@appieschot just tested it in two different projects, should be fixed now. Would you be able to validate it on your end?

@appieschot
Copy link

After updating the panel won't load anymore, anything else I need to update / check / change?

image

@estruyf
Copy link
Owner Author

estruyf commented Oct 1, 2021

Seems something went wrong during the build

@estruyf
Copy link
Owner Author

estruyf commented Oct 1, 2021

Ok, found it. Auto-import inserted something in the wrong order. Should be fixed in the next release which is currently publishing.

@estruyf
Copy link
Owner Author

estruyf commented Oct 1, 2021

Released and works again @appieschot 😁

@appieschot
Copy link

Awesome works great! Can be closed out 🚀

@estruyf estruyf added the enhancement New feature or request label Oct 3, 2021
@estruyf estruyf closed this as completed Oct 7, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants