Code Monkey home page Code Monkey logo

Comments (3)

jemus42 avatar jemus42 commented on July 28, 2024 1

Manipulating the HTML of plot output is possible right now, you could use a similar approach to knitr hooks as I did here to wrap the image in <picture> with different sources.

You could append a set suffix at the end of each source, so you have e.g. image.png for the original image and image-medium.png and image-small.png or something, which would make your HTML good to go, but at this point you only have one image actually existing, i.e. image.png.
At this point you could use a post-processing script using something like imagemagick or the magick package to crawl through your output directory, take every image that doesn't hav one of your predefined suffixes, and have it create the two image versions you references in the <picture>-tag.

It wouldn't be pretty, but the more I think about it, the more I'm certain that it's at least doable right now.

from blogdown.

jemus42 avatar jemus42 commented on July 28, 2024

I found a way to output the <picture> tag with arbitrary additional sources, and also a way to convert plot output on the fly while it's being generated to additional formats. I briefly explain and link to the relevant code in this post, and more adventurous folks might be able to build upon that approach.

from blogdown.

yihui avatar yihui commented on July 28, 2024

Yeah, on second thought, I think it makes more sense for users to redefine the plot hook to do whatever they want just like @jemus42 did. I don't want to go too deep into this rabbit hole myself. I feel the responsive <picture> is more for displaying art, and I don't see how beneficial it is to display a scatterplot in multiple versions.

from blogdown.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.