You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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)
Reacted by Clemens Brunner, Michael McCarthy, Jon Gretar Borgthorsson, Ryan Chitwood, Igor Kuivjogi Fernandes and Joe Slam
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.
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.
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)
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...)
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.
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
@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.
Activity
mcanouil commentedon Sep 6, 2022
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.
aammd commentedon Nov 13, 2022
I found this VERY challenging because the documentation states that this is possible
JonGretar commentedon Nov 19, 2022
Yeah that confuses me as well.
mcanouil commentedon Nov 19, 2022
Is this issue not fixed using the "preview-image" class as stated in the documentation? (I do not know since when)
JonGretar commentedon Nov 24, 2022
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.
dragonstyle commentedon Feb 24, 2023
starting in the next pre-release, this should be supported like so:
cscheid commentedon Feb 24, 2023
(@dragonstyle I think I need to do this for mermaid charts, dot, etc)
dragonstyle commentedon Feb 24, 2023
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...)
cscheid commentedon Feb 24, 2023
great, I'll get back to you on this when mermaid+dot are back into rendering static PNG and SVG correctly.
cscheid commentedon Dec 5, 2023
This works on v1.4 right now:
One caveat is that users need to specify
mermaid-format: pngso 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.produnis commentedon Feb 20, 2024
currently (quarto 1.4.550),
#| classes: preview-imageseems 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-imageto a specific plot chunkcderv commentedon Feb 21, 2024
@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!