I am currently trying to develop a plugin for Jekyll that would help use Cloudinary for responsive images. Current source is in my Github repo, I will make it a gem later when/if it works.
This plugin has two features:
- a Liquid tag to define Cloudinary images like
{% cloudinary [preset] path/to/img.jpg [attr="value"] %}
- a Converter to optionnaly automate transformation of standard Markdown/Kramdown syntax for images into this Liquid tag:
{:caption="caption text"}
becomes{% cloudinary path/to/img.jpg alt="alt text" caption="caption text" %}
Currently, both features work as intended, but they're not "chained". If I use the Liquid tag in my Markdown, it is evaluated. If I put a standard Markdown image, it is converted to the {% cloudinary … %}
Liquid tag, but this tag is not evaluated.
I suspect the two features are not run in the right order, so I want to make sure the Converter is executed before the Liquid tag is evaluated.
But I didn't yet understand how to use the priority flag.
If I uncomment the priority :normal
line in my plugin, and run bundle exec jekyll serve
, I get this error:
$ bundle exec jekyll serve
Configuration file: /Users/nhoizey/Dropbox/Personnel/Devs/nicolas-hoizey.com/_config.yml
jekyll 3.1.6 | Error: undefined method `priority' for Jekyll::CloudinaryTag:Class
Did you mean? print
Any idea?
EDIT (July 11th):
I have now split it into to plugins.
The Converter is still in my site's _plugins
folder: https://github.com/nhoizey/nicolas-hoizey.com/blob/52c92a38410e133890eea6044a033cb20344b971/_plugins/cloudinaryfy.rb#L26
Jekyll doesn't complain with this "priority" flag.
The Liquid tag is now a true autonomous plugin gem named jekyll-cloudinary
: https://nhoizey.github.io/jekyll-cloudinary/
If I put the "priority" flag in this plugin, I still get the error:
$ bundle exec jekyll serve bundler: failed to load command: jekyll (/usr/local/bin/jekyll)
Bundler::GemRequireError: There was an error while trying to load the gem 'jekyll-cloudinary'.
Gem Load Error is: undefined method `priority' for Jekyll::Cloudinary::CloudinaryTag:Class
Did you mean? print
Backtrace for gem load error is:
/usr/local/lib/ruby/gems/2.3.0/gems/jekyll-cloudinary-1.2.2/lib/jekyll/cloudinary.rb:5:in `<class:CloudinaryTag>'
/usr/local/lib/ruby/gems/2.3.0/gems/jekyll-cloudinary-1.2.2/lib/jekyll/cloudinary.rb:4:in `<module:Cloudinary>'
/usr/local/lib/ruby/gems/2.3.0/gems/jekyll-cloudinary-1.2.2/lib/jekyll/cloudinary.rb:2:in `<module:Jekyll>'
/usr/local/lib/ruby/gems/2.3.0/gems/jekyll-cloudinary-1.2.2/lib/jekyll/cloudinary.rb:1:in `<top (required)>'
/usr/local/lib/ruby/gems/2.3.0/gems/jekyll-cloudinary-1.2.2/lib/jekyll-cloudinary.rb:1:in `require'
/usr/local/lib/ruby/gems/2.3.0/gems/jekyll-cloudinary-1.2.2/lib/jekyll-cloudinary.rb:1:in `<top (required)>'
/usr/local/lib/ruby/gems/2.3.0/gems/bundler-1.12.5/lib/bundler/runtime.rb:86:in `require'
/usr/local/lib/ruby/gems/2.3.0/gems/bundler-1.12.5/lib/bundler/runtime.rb:86:in `block (2 levels) in require'
/usr/local/lib/ruby/gems/2.3.0/gems/bundler-1.12.5/lib/bundler/runtime.rb:81:in `each'
/usr/local/lib/ruby/gems/2.3.0/gems/bundler-1.12.5/lib/bundler/runtime.rb:81:in `block in require'
/usr/local/lib/ruby/gems/2.3.0/gems/bundler-1.12.5/lib/bundler/runtime.rb:70:in `each'
/usr/local/lib/ruby/gems/2.3.0/gems/bundler-1.12.5/lib/bundler/runtime.rb:70:in `require'
/usr/local/lib/ruby/gems/2.3.0/gems/bundler-1.12.5/lib/bundler.rb:102:in `require'
/usr/local/lib/ruby/gems/2.3.0/gems/jekyll-3.1.6/lib/jekyll/plugin_manager.rb:34:in `require_from_bundler'
/usr/local/lib/ruby/gems/2.3.0/gems/jekyll-3.1.6/bin/jekyll:9:in `<top (required)>'
/usr/local/bin/jekyll:22:in `load'
/usr/local/bin/jekyll:22:in `<top (required)>'
/usr/local/lib/ruby/gems/2.3.0/gems/bundler-1.12.5/lib/bundler/cli/exec.rb:63:in `load'
/usr/local/lib/ruby/gems/2.3.0/gems/bundler-1.12.5/lib/bundler/cli/exec.rb:63:in `kernel_load'
/usr/local/lib/ruby/gems/2.3.0/gems/bundler-1.12.5/lib/bundler/cli/exec.rb:24:in `run'
/usr/local/lib/ruby/gems/2.3.0/gems/bundler-1.12.5/lib/bundler/cli.rb:304:in `exec'
/usr/local/lib/ruby/gems/2.3.0/gems/bundler-1.12.5/lib/bundler/vendor/thor/lib/thor/command.rb:27:in `run'
/usr/local/lib/ruby/gems/2.3.0/gems/bundler-1.12.5/lib/bundler/vendor/thor/lib/thor/invocation.rb:126:in `invoke_command'
/usr/local/lib/ruby/gems/2.3.0/gems/bundler-1.12.5/lib/bundler/vendor/thor/lib/thor.rb:359:in `dispatch'
/usr/local/lib/ruby/gems/2.3.0/gems/bundler-1.12.5/lib/bundler/vendor/thor/lib/thor/base.rb:440:in `start'
/usr/local/lib/ruby/gems/2.3.0/gems/bundler-1.12.5/lib/bundler/cli.rb:11:in `start'
/usr/local/lib/ruby/gems/2.3.0/gems/bundler-1.12.5/exe/bundle:27:in `block in <top (required)>'
/usr/local/lib/ruby/gems/2.3.0/gems/bundler-1.12.5/lib/bundler/friendly_errors.rb:98:in `with_friendly_errors'
/usr/local/lib/ruby/gems/2.3.0/gems/bundler-1.12.5/exe/bundle:19:in `<top (required)>'
/usr/local/bin/bundle:22:in `load'
/usr/local/bin/bundle:22:in `<main>'
Bundler Error Backtrace:
/usr/local/lib/ruby/gems/2.3.0/gems/bundler-1.12.5/lib/bundler/runtime.rb:89:in `rescue in block (2 levels) in require'
/usr/local/lib/ruby/gems/2.3.0/gems/bundler-1.12.5/lib/bundler/runtime.rb:85:in `block (2 levels) in require'
/usr/local/lib/ruby/gems/2.3.0/gems/bundler-1.12.5/lib/bundler/runtime.rb:81:in `each'
/usr/local/lib/ruby/gems/2.3.0/gems/bundler-1.12.5/lib/bundler/runtime.rb:81:in `block in require'
/usr/local/lib/ruby/gems/2.3.0/gems/bundler-1.12.5/lib/bundler/runtime.rb:70:in `each'
/usr/local/lib/ruby/gems/2.3.0/gems/bundler-1.12.5/lib/bundler/runtime.rb:70:in `require'
/usr/local/lib/ruby/gems/2.3.0/gems/bundler-1.12.5/lib/bundler.rb:102:in `require'
/usr/local/lib/ruby/gems/2.3.0/gems/jekyll-3.1.6/lib/jekyll/plugin_manager.rb:34:in `require_from_bundler'
/usr/local/lib/ruby/gems/2.3.0/gems/jekyll-3.1.6/bin/jekyll:9:in `<top (required)>'
/usr/local/bin/jekyll:22:in `load'
/usr/local/bin/jekyll:22:in `<top (required)>'
Why is it working for one plugin but not the other?
How can I make sure the cloudinarify
Converter plugin runs before the jekyll-cloudinary
Liquid tag is interpreted?