A Jekyll plugin that updates specific image links to be served and resized through https://images.weserv.nl/.
Add the following to your site's Gemfile
:
gem 'jekyll-image-cache'
add the following to your site's _config.yml
:
plugins:
- jekyll-image-cache
Note: if jekyll --version
is less than 3.5
use:
gems:
- jekyll-image-cache
In your terminal, execute:
bundle
(re)start your Jekyll server with:
jekyll serve
Add the u-photo
class to any image you wish to be cached and resized (width of 640px) on https://images.weserv.nl/, either using Markdown syntax:
{:class="u-photo"}
... or HTML syntax:
<img src="https://example.com/images/photo.jpg" alt="Image alt" class="u-photo">
The resulting images will be rendered with a src
URL of: //images.weserv.nl/?url=example.com/images/photo.jpg&w=640
💡 Tip: Note that the github-pages
gem runs in safe
mode and only allows a defined set of plugins. To use this gem in GitHub Pages, you need to build your site locally or use a CI (e.g. Github Workflow) and deploy to your gh-pages
branch. Click here for more information.