Skip to content

Simple image resizing filter for Jekyll 3 and 4 🖼 🤏 🔬

License

MIT, MIT licenses found

Licenses found

MIT
LICENSE
MIT
LICENSE-source
Notifications You must be signed in to change notification settings

MichaelCurrin/jekyll-resize

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

30 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Jekyll Resize

Image resizing tag for Jekyll 4

Made with Ruby GitHub tag MIT license

Supports:

  • Jekyll

Create resized images at build time when making a Jekyll static site.

Sample

{{ image_path | resize: '800x800>' }}

See more details in Usage section.

About

Forked from CloudCannon/jekyll-resize (RubyGems jekyll-resize) to add Jekyll 4 support for my projects.

Notable changes:

  • Updated jekyll-resize.gemspec to use Jekyll 4.
  • Added require "mini_magick" to the jekyll-resize.rb file to avoid a runtime error as constant MiniMagick::Image not defined (this error was not present on Jekyll 3).
  • Created README.md file.

Requirements

  • Ruby
  • Jekyll 3 or 4
  • GraphicsMagick

Internal dependencies

  • minimagick/minimagick
    • A ruby wrapper for ImageMagick or GraphicsMagick command line.

    • Sample use is covered in the readme - e.g. image.resize "100x100".

Installation

Install system dependencies

Install project dependencies

  1. Recommended - add Jekyll as a project gem:
    source 'https://rubygems.org'
    
    gem 'jekyll', '~> 4.0.1'
  2. Add jekyll-resize to your project's Gemfile:
    group :jekyll_plugins do
    gem 'jekyll-resize', git: 'https://github.com/MichaelCurrin/jekyll-resize'
    end
  3. Install your project's gems.
    $ bundle install

Configure

Add to your .gitignore file:

cache/

Usage

This plugin makes the resize tag available.

resize: OPTIONS

Pass an image path to the tag so it can be resized and saved to cache/resize/.

Examples

{{ image_path | resize: "800x800>" }}
[My image]({{ image_path | resize: "800x800>" }})

Output

Sample output logged on build:

Thumbnailing .../my-project/uploads/1.jpg to .../my-project/cache/resize/c673c80c6...5a92_800x800.jpg (800x800>)

Sample filename in cache/resize/ - it's much longer that this.

c673c80c6...5a92_800x800.jpg

Contributing

Submit a Pull Request if you have improvments.

Development

Commit and push changes. You do not need to tag.

Run this in another project to get the latest version of the gem.

$ bundle update

License

Released under MIT.

Original license - MIT.