Image resizing tag for Jekyll 4
Supports:
Create resized images at build time when making a Jekyll static site.
{{ image_path | resize: '800x800>' }}
See more details in Usage section.
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 constantMiniMagick::Image
not defined (this error was not present on Jekyll 3). - Created README.md file.
- Ruby
- Jekyll 3 or 4
- GraphicsMagick
- minimagick/minimagick
-
A ruby wrapper for ImageMagick or GraphicsMagick command line.
- Sample use is covered in the readme - e.g.
image.resize "100x100"
.
-
- Install GraphicsMagick.
- Install Ruby and Bundler (recommended) at the user level.
- Recommended - add Jekyll as a project gem:
source 'https://rubygems.org' gem 'jekyll', '~> 4.0.1'
- Add
jekyll-resize
to your project'sGemfile
:group :jekyll_plugins do gem 'jekyll-resize', git: 'https://github.com/MichaelCurrin/jekyll-resize' end
- Install your project's gems.
$ bundle install
Add to your .gitignore
file:
cache/
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/
.
{{ image_path | resize: "800x800>" }}
[My image]({{ image_path | resize: "800x800>" }})
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
Submit a Pull Request if you have improvments.
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
Released under MIT.
Original license - MIT.