简体   繁体   中英

Knitr, convert to base64 and CSS style

I'm a little new to this great library (and HTML) so this might be a noob question.

I have a situation that I'm unable for figure out - how can I add some CSS styling to an image while also encoding it in base64? This is the code in my Rmarkdown file (which I pass to knit2html ) -

<img src="SomeImage.png", width = "75%", border = "2"> # converts to base64 with width and border correctly applied
<img class="displayed", src="SomeImage.png"> # does not convert to base64, points to local path with style correctly applied

Is there any way to get the second one to convert to base64 while applying the style too? Or am I doing something wrong?

SessionInfo , if needed -

> sessionInfo()
R version 3.0.2 (2013-09-25)
Platform: x86_64-w64-mingw32/x64 (64-bit)

other attached packages:
 [1] markdown_0.6.5   xtable_1.7-1     knitr_1.5        audio_0.1-4      ggplot2_0.9.3.1 
 [6] scales_0.2.3     stringr_0.6.2    reshape2_1.2.2   reshape_0.8.4    plyr_1.8        
[11] data.table_1.9.2

Thanks!

Try this:

<style>
.displayed { border: solid 1px; }
</style>

<img src="Rplot001.png" class="displayed">

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM