jekyll-cloudinary 1.10.0 → 1.11.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 10cac9d46be9b8c5611fd0f8eb1ab07f5a5fa5c046412416b432b8db262b8cff
4
- data.tar.gz: 50ef893924e47349aa487fc4d397206ce8251614bec23568695d186d43a89b79
3
+ metadata.gz: d566836601d88ffc55930222ed7005e7eefc4c8ccdba3c7387f6aed951340a37
4
+ data.tar.gz: 92cddd4c72dbe6a5c3fa8bbd99ca94db1f14d0a263a931c3e4f8ed6a6a414913
5
5
  SHA512:
6
- metadata.gz: f7e170f3f7938f0dfad0d23bb9c5130c1eb98ee168e5a85ede82128f25451ae4b9f068730baa94caf317009d5525b7143cfddb8bddc492f6943b573ffb97dd9a
7
- data.tar.gz: 81ff00d2955764a80af6cce8efc98fc3b371b08a8859b0af8cc5d27f7ff786c88d614ec49bb98fb453de16e793010eac002e0a250440ca7d38a18a51e6a4cef0
6
+ metadata.gz: 2bc137c4cf81c3bb6afca1d75c95da329bd3ce7df4291f81b8a122b16ecc7366f05156616323a28dff733a06e790d0a6dd0bdb9b6ddc577c1dcad031535da9cf
7
+ data.tar.gz: fd53a488072d3c1cc56d4d91475de5b595ee00d248683f826c1cb7c96f3f5f9139b54773c7410532a4b7feedfd143077c1089c270789c4d470c37470c3da47df
data/README.md CHANGED
@@ -25,6 +25,7 @@ Here is the general syntax of this Liquid tag:
25
25
  - [Configuration](#configuration)
26
26
  - [Mandatory settings](#mandatory-settings)
27
27
  - [Optional global settings](#optional-global-settings)
28
+ - [`only_prod` (default: `false`)](#only_prod-default-false)
28
29
  - [`verbose` (default: `false`)](#verbose-default-false)
29
30
  - [Optional (but highly recommended) presets](#optional-but-highly-recommended-presets)
30
31
  - [Default preset](#default-preset)
@@ -79,9 +80,23 @@ You can now define some global settings
79
80
  ```yaml
80
81
  cloudinary:
81
82
 
83
+ only_prod: true
82
84
  verbose: true
83
85
  ```
84
86
 
87
+ #### `only_prod` (default: `false`)
88
+
89
+ When set to `true`, this setting implies that responsive image HTML and Cloudinary URLs are generated only if the environnement is `production`.
90
+
91
+ For example:
92
+
93
+ - if you run `JEKYLL_ENV=production bundle exec jekyll build`, you'll get the code to deploy, with `srcset` and Cloudinary URLs.
94
+ - if you run `JEKYLL_ENV=development bundle exec jekyll serve`, you'll get code for local development, with standard `<img src="…">` code and local URLs.
95
+
96
+ [`JEKYLL_ENV=development` is the default value](https://jekyllrb.com/docs/configuration/#specifying-a-jekyll-environment-at-build-time).
97
+
98
+ If you don't set `only_prod` or set it to `false`, responsive image HTML and Cloudinary URLs are always generated, whatever the environment. jekyll-cloudinary had only this behavior before version 1.11.0.
99
+
85
100
  #### `verbose` (default: `false`)
86
101
 
87
102
  When set to `true`, this setting will show messages in the console when something goes wrong, such as:
@@ -11,6 +11,11 @@ module Jekyll
11
11
 
12
12
  def render(context)
13
13
  # Default settings
14
+ settings_defaults = {
15
+ "cloud_name" => "",
16
+ "only_prod" => false,
17
+ "verbose" => false,
18
+ }
14
19
  preset_defaults = {
15
20
  "min_width" => 320,
16
21
  "max_width" => 1200,
@@ -19,7 +24,6 @@ module Jekyll
19
24
  "sizes" => "100vw",
20
25
  "figure" => "auto",
21
26
  "attributes" => {},
22
- "verbose" => false,
23
27
  "width_height" => true,
24
28
  # Cloudinary transformations
25
29
  "height" => false,
@@ -85,7 +89,11 @@ module Jekyll
85
89
  site = context.registers[:site]
86
90
  url = site.config["url"]
87
91
  baseurl = site.config["baseurl"] || ""
88
- settings = site.config["cloudinary"]
92
+ settings = settings_defaults.merge(site.config["cloudinary"])
93
+
94
+ if settings["cloud_name"] == ""
95
+ Jekyll.logger.abort_with("[Cloudinary]", "You must set your cloud_name in _config.yml")
96
+ end
89
97
 
90
98
  # Get Markdown converter
91
99
  markdown_converter = site.find_converter_instance(::Jekyll::Converters::Markdown)
@@ -196,6 +204,10 @@ module Jekyll
196
204
  image_dest_path = image_src
197
205
  image_dest_url = image_src
198
206
  natural_width, natural_height = FastImage.size(image_dest_url)
207
+ if natural_width.nil?
208
+ Jekyll.logger.warn("remote url doesn't exists " + image_dest_url)
209
+ return "<img src=\"#{image_dest_url}\" />"
210
+ end
199
211
  width_height = "width=\"#{natural_width}\" height=\"#{natural_height}\""
200
212
  fallback_url = "https://res.cloudinary.com/#{settings["cloud_name"]}/image/#{type}/#{transformations_string}w_#{preset["fallback_max_width"]}/#{image_dest_url}"
201
213
  else
@@ -248,6 +260,11 @@ module Jekyll
248
260
  end
249
261
  end
250
262
 
263
+ # Don't generate responsive image HTML and Cloudinary URLs for local development
264
+ if settings["only_prod"] && ENV["JEKYLL_ENV"] != "production"
265
+ return "<img src=\"#{image_dest_url}\" #{attr_string} #{img_attr} #{width_height}/>"
266
+ end
267
+
251
268
  srcset = []
252
269
  steps = preset["steps"].to_i
253
270
  min_width = preset["min_width"].to_i
@@ -1,5 +1,5 @@
1
1
  module Jekyll
2
2
  module Cloudinary
3
- VERSION = "1.10.0".freeze
3
+ VERSION = "1.11.0".freeze
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jekyll-cloudinary
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.10.0
4
+ version: 1.11.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nicolas Hoizey
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-05-11 00:00:00.000000000 Z
11
+ date: 2018-05-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: jekyll