Simple image resizing filter for Jekyll 3 and 4
Add the plugin gem to your Gemfile as below, then install it with Bundler.
group :jekyll_plugins do
gem "jekyll-resize", git: "https://github.com/MichaelCurrin/jekyll-resize"
end
The resize
filter will be available in Liquid (in your Markdown and HTML) so you can use it for a JPEG or PNG file.
Here we resize an image to max width and max height of 800 pixels:
{{ "my-image.png" | resize: "800x800>" }}
That takes care of:
- generating the reduced image.
- providing a link to the file.
See the docs linked below for a more detailed example using the filter with an HTML img
tag.
Why you should use this plugin and how to install and use it in a Jekyll project
See Contributing doc.
Released under MIT by @MichaelCurrin.
Original license - MIT.
This project was forked from the CloudCannon/jekyll-resize repo (jekyll-resize on RubyGems). So that I could use this in my Jekyll 4 project and so others can too.
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 this
README.md
file and the docs directory.