DEVHIDE
        • Home (current)
        • About
        • Contact
        • Cookie
        • Home (current)
        • About
        • Contact
        • Cookie
        • Disclaimer
        • Privacy
        • TOS
        Login Or Sign up

        Jekyll thumbnail plugin with Liquid tag

        1.3k Views Asked by tekknolagi At 10 January 2014 at 17:40 2025-12-21T08:40:04.738473

        I am trying to use a loop over a Data File with Jekyll. The code I have is as follows:

        <div class="row">
          <div class="12 columns">
            <ul class="clearing-thumbs" data-clearing>
              {% for photo in site.data.unusable_photos %}
                <li><a href="{{ photo.path }}" class="th"><img class="album-photo" data-caption="{{ photo.caption }}" src="{{ photo.thumb }}"></a></li>
              {% endfor %}
            </ul>
          </div>
        </div>
        

        However, it's getting hard to manually generate thumbnails for every photo I have. I found the Jekyll plugin thumbnail, but I don't know how to make it fit my needs.

        The README shows this example: {% thumbnail /path/to/local/image.png 50x50< %}.

        How can I use the {{ photo.path }} with the Jekyll plugin, so that I don't have to manually type filenames?

        EDIT: Maybe I can edit the plugin so it can access the site variable?

        ruby jekyll liquid jekyll-extensions
        Original Q&A
        1

        There are 1 best solutions below

        0
        Kevin Chen Kevin Chen On 11 August 2014 at 01:49

        I made a modified version of thumbnailer that looks up what you put as path as a variable if it does not exist on disk. The magic happens in the call to look_up.

        def look_up(context, name)
          lookup = context
        
          name.split(".").each do |value|
            lookup = lookup[value]
          end
        
          lookup
        end
        

        Then in render(context), call look_up:

        source = look_up context, source unless File.readable?(source)
        

        Full code: https://github.com/kevin1/jekyll-thumbnailer/blob/master/thumbnail.rb

        Related Questions in RUBY

        • how to integrate cashfree payment gateway in ruby on rails project
        • RSpec Capybara throwing Selenium error when trying to click a button with browser confirm
        • Duplicate GET requests - Rails & Heroku
        • convert csv file with json data inside to a column, rows table in 2nd csv file
        • Installing dependencies from a gemspec file
        • Verifying Google Identity OAuth2 token with Ruby
        • Java code of AES/GCM/NoPadding encryption algorithm with authentication tag
        • How to fix error in model with gem lockbox
        • Cannot install Ruby Gem on Window
        • use logstash filter ,aes gcm encrypted in ruby,but cannot decrypted in java
        • In Rails 7, what is the right ActiveRecord callback to use if I need to prevent (or rollback) persistance on error?
        • How can I go through an array and still remove elements from it
        • Nokogiri only returning 5 results
        • How do I get the fullscreen mode in firefox?
        • undefined group option when using branch reset group regex in Ruby

        Related Questions in JEKYLL

        • How do I change the main page in jekyll hydejack theme in github blog?
        • TZInfo::DataSources::ZoneinfoDirectoryNotFound
        • How to fence code blocks with line numbers correctly and update the code-block CSS
        • How can I add audio and video with selectable tracks to a Jekyll personal blog?
        • Jekyll: Conversion error: Jekyll::Converters::Scss encountered an error while converting 'assets/main.scss': Broken pipe
        • How does Jekyll apply `include` outside of `<body>` tag?
        • static website with Jekyll: bundler: failed to load command: jekyll
        • How to tell jekyll-build to skip a file that I don't want it to build?
        • Rendering p5.js sketch on my Jekyll website
        • Trouble installing libv8 to use with mini_racer (github page site project using Git bash)
        • Cannot locally serve jekyll using existing site
        • sort and sort_natural in Jekyll Liquid seem to produce different results
        • Automatic dynamic header with Jekyll?
        • Github pages: how to redirect error url to 404.html page with nojekyll
        • How to set a default date on a Jekyll site?

        Related Questions in LIQUID

        • Remove specific products from cart on change in shopify
        • Blogs Standard URL Filter /Tagged/Tag Not Working - Shopify
        • Liquid Template - How to map JSON object as a string to output field
        • Eleventy site builder: Make JavaScript function available for Nunjucks templates
        • Looker: Comparing Dynamic Dates with Liquid
        • Liquibase 4.26 while importing the csv file it's taking long time
        • Fill missing elements with previous one - Liquid, Shopify
        • How to call a Cart Drawer in custom product section?
        • Shopify Metafield List of Collections
        • How would I close this space up on the right? Using Shopify liquid
        • Unable to build dynamic iterative lists
        • Resetting loop count on liquid on condition
        • window.Shopify.settings is undefined. How do I access Shopify theme settings in JavaScript?
        • How does Jekyll apply `include` outside of `<body>` tag?
        • Checkout Page in Shopify

        Related Questions in JEKYLL-EXTENSIONS

        • How do I force a gem file to be installed when the the dependency doesn't match?
        • Format Jekyll/Liquid number needing commas included
        • Jekyll plugin that adds loading="lazy" to all images?
        • I want to add giscus comment to all jekyll posts but it doesn't work
        • Create array in Jekyll page/post using Liquid tag
        • Jekyll and SEO friendly pagination
        • Trailing slash on void elements has no effect and interacts badly with unquoted attribute values. (Fix for Jekyll Seo Tag plugin & HTML5)
        • I use jekyll and need a glossary tooltip that dynamically finds the terms
        • Search by 2D position (distance) in Jekyll blog
        • Tags and Category list pages for blog not loading on Jekyll Site
        • Trouble getting a specific version of Jekyll - Windows
        • Can't install gem jekyll-content-security-policy-generator in Jekyll
        • Redirect URLs with Jekyll
        • Implementing a glossary in Jekyll
        • Custom citation style with Jekyll Scholar

        Trending Questions

        • UIImageView Frame Doesn't Reflect Constraints
        • Is it possible to use adb commands to click on a view by finding its ID?
        • How to create a new web character symbol recognizable by html/javascript?
        • Why isn't my CSS3 animation smooth in Google Chrome (but very smooth on other browsers)?
        • Heap Gives Page Fault
        • Connect ffmpeg to Visual Studio 2008
        • Both Object- and ValueAnimator jumps when Duration is set above API LvL 24
        • How to avoid default initialization of objects in std::vector?
        • second argument of the command line arguments in a format other than char** argv or char* argv[]
        • How to improve efficiency of algorithm which generates next lexicographic permutation?
        • Navigating to the another actvity app getting crash in android
        • How to read the particular message format in android and store in sqlite database?
        • Resetting inventory status after order is cancelled
        • Efficiently compute powers of X in SSE/AVX
        • Insert into an external database using ajax and php : POST 500 (Internal Server Error)

        Popular # Hahtags

        javascript python java c# php android html jquery c++ css ios sql mysql r reactjs node.js arrays c asp.net json

        Popular Questions

        • How do I undo the most recent local commits in Git?
        • How can I remove a specific item from an array in JavaScript?
        • How do I delete a Git branch locally and remotely?
        • Find all files containing a specific text (string) on Linux?
        • How do I revert a Git repository to a previous commit?
        • How do I create an HTML button that acts like a link?
        • How do I check out a remote Git branch?
        • How do I force "git pull" to overwrite local files?
        • How do I list all files of a directory?
        • How to check whether a string contains a substring in JavaScript?
        • How do I redirect to another webpage?
        • How can I iterate over rows in a Pandas DataFrame?
        • How do I convert a String to an int in Java?
        • Does Python have a string 'contains' substring method?
        • How do I check if a string contains a specific word?

        Copyright © 2021 Jogjafile Inc.

        • Disclaimer
        • Privacy
        • TOS
        • Homegardensmart
        • Pricesm.com
        • Aftereffectstemplates