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-03T10:23:57.176000

        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

        • Best way to make an HABTM association via console
        • undefined method `namespace' for main:Object (NoMethodError) - active record / rakefile
        • Ruby destroy is not working? Or objects still present?
        • Trying to set the value of an input with mechanize
        • How to split the logic in a ruby game
        • How can I monitor an endpoint's status with Ruby?
        • Why can a private class method be explicitly invoked in Ruby?
        • Rails - Ajax do not work properly on production server
        • syntax error, unexpected kEND
        • Carrierwave file upload with different file types
        • b.javascript_dialog().exists? is not working for me in WATIR 4.0.2
        • Combine two arrays of hashes
        • Building a simple calculator form in Rails 4
        • How do I update create route from rails 3 to 4
        • Comparison of Fixnum with nil failed - palindrome program Ruby

        Related Questions in JEKYLL

        • Jekyll install on Windows error message
        • Jekyll: Using liquid tags in .md files
        • why Special characters apostrophe and others shows like this ’, in HTMl file
        • —- " added in HTML when converting MarkDown file to HTML using Jekyll tool
        • Check if cookie exists using Jekyll Liquid
        • Show only headers in Octopress RSS
        • Grouping MarkDown elements in to DIV element or Custom html tag
        • Jekyll JSON incorrect character encoding
        • Creating a gruntfile to compile Jekyll and push a subfolder to Github
        • github page blog from jekyll needs force reload to show changes with posts
        • sorting of collection does not work
        • gulp deploy rsync error // missing module lodash
        • Jekyll: Liquid Tags used in Sub-directories
        • Setting up Polymer with Jekyll?
        • Make array elements lowercase with Liquid filters for sorting

        Related Questions in LIQUID

        • Jekyll: Using liquid tags in .md files
        • Check if cookie exists using Jekyll Liquid
        • How do you get the current time from bigcartel's server?
        • If Else Statements, Javascript Toggle, Liquid / Ruby Language
        • If, elsif, else: Limitations? Liquid
        • sorting of collection does not work
        • Shopify vendor if statement
        • Jekyll: Liquid Tags used in Sub-directories
        • Ruby on Rails liquid theme detect current page and either display banner or not
        • Make array elements lowercase with Liquid filters for sorting
        • Jekyll - How can I make avoid a paragraph to be added on a YAML frontmatter markdownify item
        • Jekyll: Liquid Capture and Markdownify Tag Issues
        • Does Liquid have a "does not contain" or "not in array" operator?
        • Jekyll Deployment on Github Pages doesn't format correctly (No styling)
        • Jekyll and Liquid for-loop

        Related Questions in JEKYLL-EXTENSIONS

        • Modifying the output of the jekyll-amazon tag
        • Loop through nested JSON elements and find a value for a custom Jekyll tag
        • Bundled So-Simple Jekyll theme not running in localhost with jekyll serve?
        • How do I add a routing rule or redirect for the root URL using the s3_website gem?
        • Custom URL for assets folder in Jekyll
        • Octopress-multilingual with octopress-paginate are not compatible with latest jekyll
        • Pandoc citation in figure caption and alt text
        • Using octopress with emacs org-mode for blogging
        • Getting parts of markdown files in Jekyll
        • Unable to find current post's category jekyll
        • Simplest way to get (jekyll-scholar) plugins on gh-pages
        • I want to add giscus comment to all jekyll posts but it doesn't work
        • jekyll-sitemap and robots.txt get wrapped in html unexpectedly when generating jekyll site
        • How can I store a hash for the lifetime of a 'jekyll build'?
        • Profile Jekyll build time

        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

        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
        • Math
        • Aftereffectstemplates