Skip to content

Use plot as blog post image #2324

Closed
Closed

Description

@cscheid

Discussed in #2319

Originally posted by 11rchitwood September 6, 2022
Let's say I have a post whose first code chunk is:

plot(cars)

How can I make this be the preview image for the post?

Being able to refer to easily refer to resources generated by the execution engines in our code is a good idea (I can imagine a similar feature being useful for the output of a dot or mermaid cell, or some arbitrary user shortcode)

Activity

  1. added
    enhancement
    on Sep 6, 2022
  2. added this to the Future milestone on Sep 6, 2022
  3. mcanouil commented on Sep 6, 2022

    @mcanouil
    Collaborator

    To note, for blog post in Quarto website, if there is an image in the folder it was taken as the preview in the listing page.
    So, it would only require to export the chunk as a raster image to the Qmd directory to have the preview.
    This could easily be done at least for knitr with reusable code cell.

    The above behaviour was observed at least until Quarto 1.0.36.
    After I updated the yaml to explicitly list the image and added alt text.
    See https://github.com/RLille/rlille.fr/tree/c6647dc8082caeadab3ec4ea32be3a4f013db192/posts/2022-01-24-golem.

  4. aammd commented on Nov 13, 2022

    @aammd

    I found this VERY challenging because the documentation states that this is possible

    The image for this item, read from the image field of the front matter, or automatically discovered by taking the first of an image of class preview-image, an image with a file name starting with feature, cover, or thumbnail, or the first image to appear in the document.

  5. JonGretar commented on Nov 19, 2022

    @JonGretar

    Yeah that confuses me as well.

    I found this VERY challenging because the documentation states that this is possible

  6. mcanouil commented on Nov 19, 2022

    @mcanouil
    Collaborator

    Is this issue not fixed using the "preview-image" class as stated in the documentation? (I do not know since when)

    ```{r}
    #| class-output: preview-image
    plot(1)
    ```
    
  7. JonGretar commented on Nov 24, 2022

    @JonGretar

    No.
    Nor does it indeed pick, if undefined, any plot as a preview image. It only picks the first static image it sees and leaves it previewless if none are found. I tried all the methods defined in the docs.

    Is this issue not fixed using the "preview-image" class as stated in the documentation? (I do not know since when)

  8. self-assigned this
    on Nov 27, 2022
  9. modified the milestones: Future, v1.3 on Nov 27, 2022
  10. dragonstyle commented on Feb 24, 2023

    @dragonstyle
    Collaborator

    starting in the next pre-release, this should be supported like so:

    ```{r}
    #| classes: preview-image
    plot(mtcars)
    ```
    
  11. self-assigned this
    on Feb 24, 2023
  12. cscheid commented on Feb 24, 2023

    @cscheid
    MemberAuthor

    (@dragonstyle I think I need to do this for mermaid charts, dot, etc)

  13. dragonstyle commented on Feb 24, 2023

    @dragonstyle
    Collaborator

    Listings will now generically discover images in the rendered output using our normal preview image semantics, so it could be as easy as improving our preview image detection to include those (which would mean they could participate in things like twitter cards, open graph, etc...)

  14. cscheid commented on Feb 24, 2023

    @cscheid
    MemberAuthor

    great, I'll get back to you on this when mermaid+dot are back into rendering static PNG and SVG correctly.

  15. modified the milestones: v1.3, v1.4 on Feb 27, 2023
  16. removed their assignment
    on Feb 27, 2023
  17. added
    bug
    and removed
    enhancement
    on Dec 4, 2023
  18. cscheid commented on Dec 5, 2023

    @cscheid
    MemberAuthor

    This works on v1.4 right now:

    image

    One caveat is that users need to specify mermaid-format: png so that the diagram is pre-rendered (instead of being a JS widget). At some point we'd like to improve that situation, but it's a different issue.

  19. produnis commented on Feb 20, 2024

    @produnis

    starting in the next pre-release, this should be supported like so:

    ```{r}
    #| classes: preview-image
    plot(mtcars)
    

    currently (quarto 1.4.550), #| classes: preview-image seems to be ignored, in my blog, the first picture from a plot chunk is picked as the preview image, no matter if I set the #| classes: preview-image to a specific plot chunk

  20. cderv commented on Feb 21, 2024

    @cderv
    Member

    @produnis could you open a new issue with a reproducible example ? Maybe there is a regression. Having a simple example (e.g create using quarto create project) will help us look into this.

    Thanks a lot!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bug

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions