jekyll-srcset-tag 0.1.2 → 0.1.3

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
  SHA1:
3
- metadata.gz: 4731a5625c94f4612a08a86acb434690e8c2a014
4
- data.tar.gz: 01ba9cd52d94b7b1b1aa06e67bd0a8f98b880c6a
3
+ metadata.gz: d49f4f1c7e777fb4ed13911378f1d5c3514e9bbd
4
+ data.tar.gz: fe446dcd3ace3765ea08d46486ec0e3dd7de1e95
5
5
  SHA512:
6
- metadata.gz: f870f6dcff942afe51be12973e2baaa5beeb81c902c3682b990240a361c2fc476be7f8dd33739f6f245935af3fe78b8f090ad94b1303aa9700ba45c474185b51
7
- data.tar.gz: ac551526bf8d16ca8c2bdfa23855374754ca2475d487c4b24846de803dffaf6a28c3c447b0a27a59ece949294ddab0b6ba68f39775093a36e84bbbfc8d74f576
6
+ metadata.gz: 48c55e164e8eda6a503048ace59081d2e22675980c38c6aa58e669eb30556ae6e29175ee64e8f806dc7c7176ebcf3c2185d5fc366b3a69d5f8c6808ded52b92b
7
+ data.tar.gz: caf01ea11c48e96231689199e37efa026491cfa900b761776b64fb4d42556e8ece7be465f3e0759f3bba269bc1dd2b9fb213d697c44b70fb060904c174c8ddd3
@@ -42,17 +42,16 @@ module Jekyll
42
42
  elsif width
43
43
  width.to_f / image_ratio
44
44
  else
45
- image_height
45
+ image_height.to_f
46
46
  end
47
-
48
47
  generated_ratio = generated_width / generated_height
49
48
 
50
49
  if image_width < generated_width || image_height < generated_height
51
50
  @undersized = true
52
- generated_width = if image_ratio > generated_ratio
51
+ generated_width = if image_ratio < generated_ratio
53
52
  image_width
54
53
  else
55
- image_height / generated_ratio
54
+ image_height * generated_ratio
56
55
  end
57
56
  generated_height = if image_ratio > generated_ratio
58
57
  image_height
@@ -35,9 +35,11 @@ module Jekyll
35
35
  def to_html
36
36
  srcs = image_srcs
37
37
  src = CGI.escape_html(srcs.last[0])
38
+ show_srcset = srcs.length > 1
38
39
  srcset = CGI.escape_html(srcs.map {|path, size| "#{path} #{size}w" }.join(', '))
39
40
  sizes = CGI::escape_html(source_sizes.join(', '))
40
- "<img src=\"#{src}\" srcset=\"#{srcset}\" sizes=\"#{sizes}\" #{html_attributes}/>\n"
41
+ srcset_attrs = show_srcset ? " srcset=\"#{srcset}\" sizes=\"#{sizes}\"" : ''
42
+ "<img src=\"#{src}\"#{srcset_attrs} #{html_attributes}/>\n"
41
43
  end
42
44
 
43
45
  def digest
@@ -1,5 +1,5 @@
1
1
  module Jekyll
2
2
  module SrcsetTag
3
- VERSION = '0.1.2'
3
+ VERSION = '0.1.3'
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jekyll-srcset-tag
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kevin Dew
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-11-11 00:00:00.000000000 Z
11
+ date: 2015-11-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: jekyll