In this post, I tried to explain how to build a gallery with a simple example. ![]() ![]() # Make list of tidytuesday plots I want to show in the gallery The purpose of the function below is to download a plot for a specific week in a specific year in the repo containing my plots. Therefore, I created a function to make it as easy as possible for me to update the plots I want to display in the gallery. I have started participating to #tidytuesday this year, and the main reason I wanted to create a gallery was to display my favorite plots. If you haven’t set up GitHub Actions yet, you can check my previous post, or check my current GitHub Actions for this site. We also have to add magick and httr in the list of packages to install. We need to add fs::dir_copy("_gallery/img", "_site/_gallery/img") in GitHub Actions so that the images are found when the gallery is built. LightGallery(document.getElementById('lightgallery')) We can just copy-paste it in an R Markdown file. We now have to add the CSS and the JavaScript code. First, I create a function to resize a single image, and I will apply it to all the images I have: To automatically create these thumbnails, we can use the function image_resize() in the package magick. ![]() As we saw above, lightgallery.js also requires thumbnails in addition to full-size images. getElementById( 'lightgallery')) #lightgallery > a > img :hover Make the gallery with R Create thumbnailsįirst, store your (full-size) images in a folder, let’s say _gallery/img. Sunset Serenity A gorgeous Sunset tonight captured at Coniston Water.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |