jekyll-image-size 0.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.gitignore +2 -0
- data/.rspec +1 -0
- data/.travis.yml +11 -0
- data/Gemfile +4 -0
- data/Gemfile.lock +89 -0
- data/LICENSE +21 -0
- data/README.md +124 -0
- data/Rakefile +1 -0
- data/jekyll-image-size.gemspec +25 -0
- data/lib/jekyll-image-size.rb +72 -0
- data/lib/jekyll-image-size/version.rb +5 -0
- metadata +127 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 2885846141a821f22f088d046af19d19d18b5ab0
|
4
|
+
data.tar.gz: 7b253d022c582aa09443f4a029f9009b2ad85f6c
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: c57b57fd19663b0f8b1711cae4bb1e0f8413ae361fc3a53e20f676d814e3ba9d21ff9c579f818ed2ffc7d13a064d44a98bc15c3ac8145375e20c7354ef5a2b82
|
7
|
+
data.tar.gz: 44da0133e64673cdb337a6a78b477f4294510024f3c1f3ca092a54b53895e1e320e1df890855ff0dce1761453680bc1cc284941968d68b79078c0d6d102014b9
|
data/.gitignore
ADDED
data/.rspec
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
--require spec_helper
|
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,89 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
jekyll-image-size (0.3.1)
|
5
|
+
fastimage (>= 1.8)
|
6
|
+
jekyll (>= 3.7)
|
7
|
+
|
8
|
+
GEM
|
9
|
+
remote: https://rubygems.org/
|
10
|
+
specs:
|
11
|
+
addressable (2.6.0)
|
12
|
+
public_suffix (>= 2.0.2, < 4.0)
|
13
|
+
colorator (1.1.0)
|
14
|
+
concurrent-ruby (1.1.5)
|
15
|
+
diff-lcs (1.3)
|
16
|
+
em-websocket (0.5.1)
|
17
|
+
eventmachine (>= 0.12.9)
|
18
|
+
http_parser.rb (~> 0.6.0)
|
19
|
+
eventmachine (1.2.7)
|
20
|
+
fastimage (2.1.5)
|
21
|
+
ffi (1.11.1)
|
22
|
+
forwardable-extended (2.6.0)
|
23
|
+
http_parser.rb (0.6.0)
|
24
|
+
i18n (0.9.5)
|
25
|
+
concurrent-ruby (~> 1.0)
|
26
|
+
jekyll (3.8.6)
|
27
|
+
addressable (~> 2.4)
|
28
|
+
colorator (~> 1.0)
|
29
|
+
em-websocket (~> 0.5)
|
30
|
+
i18n (~> 0.7)
|
31
|
+
jekyll-sass-converter (~> 1.0)
|
32
|
+
jekyll-watch (~> 2.0)
|
33
|
+
kramdown (~> 1.14)
|
34
|
+
liquid (~> 4.0)
|
35
|
+
mercenary (~> 0.3.3)
|
36
|
+
pathutil (~> 0.9)
|
37
|
+
rouge (>= 1.7, < 4)
|
38
|
+
safe_yaml (~> 1.0)
|
39
|
+
jekyll-sass-converter (1.5.2)
|
40
|
+
sass (~> 3.4)
|
41
|
+
jekyll-watch (2.2.1)
|
42
|
+
listen (~> 3.0)
|
43
|
+
kramdown (1.17.0)
|
44
|
+
liquid (4.0.3)
|
45
|
+
listen (3.1.5)
|
46
|
+
rb-fsevent (~> 0.9, >= 0.9.4)
|
47
|
+
rb-inotify (~> 0.9, >= 0.9.7)
|
48
|
+
ruby_dep (~> 1.2)
|
49
|
+
mercenary (0.3.6)
|
50
|
+
pathutil (0.16.2)
|
51
|
+
forwardable-extended (~> 2.6)
|
52
|
+
public_suffix (3.1.1)
|
53
|
+
rake (10.5.0)
|
54
|
+
rb-fsevent (0.10.3)
|
55
|
+
rb-inotify (0.10.0)
|
56
|
+
ffi (~> 1.0)
|
57
|
+
rouge (3.7.0)
|
58
|
+
rspec (3.8.0)
|
59
|
+
rspec-core (~> 3.8.0)
|
60
|
+
rspec-expectations (~> 3.8.0)
|
61
|
+
rspec-mocks (~> 3.8.0)
|
62
|
+
rspec-core (3.8.2)
|
63
|
+
rspec-support (~> 3.8.0)
|
64
|
+
rspec-expectations (3.8.4)
|
65
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
66
|
+
rspec-support (~> 3.8.0)
|
67
|
+
rspec-mocks (3.8.1)
|
68
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
69
|
+
rspec-support (~> 3.8.0)
|
70
|
+
rspec-support (3.8.2)
|
71
|
+
ruby_dep (1.5.0)
|
72
|
+
safe_yaml (1.0.5)
|
73
|
+
sass (3.7.4)
|
74
|
+
sass-listen (~> 4.0.0)
|
75
|
+
sass-listen (4.0.0)
|
76
|
+
rb-fsevent (~> 0.9, >= 0.9.4)
|
77
|
+
rb-inotify (~> 0.9, >= 0.9.7)
|
78
|
+
|
79
|
+
PLATFORMS
|
80
|
+
ruby
|
81
|
+
|
82
|
+
DEPENDENCIES
|
83
|
+
bundler (~> 2)
|
84
|
+
jekyll-image-size!
|
85
|
+
rake (~> 10.0)
|
86
|
+
rspec (~> 3.0)
|
87
|
+
|
88
|
+
BUNDLED WITH
|
89
|
+
2.0.2
|
data/LICENSE
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
MIT License
|
2
|
+
|
3
|
+
Copyright (c) General UI LLC and its affiliates.
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
13
|
+
copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
21
|
+
SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,124 @@
|
|
1
|
+
# Jekyll-Image-Size 
|
2
|
+
|
3
|
+
Jekyll tag-plugin to read image sizes from a static asset and output them in one of many formats.
|
4
|
+
|
5
|
+
Uses:
|
6
|
+
|
7
|
+
* generate your opengraph og:image:height and og:image:width tags
|
8
|
+
* IMG tags for retina-resolution assets (@2x, @3x, etc...)
|
9
|
+
* Generate CSS or HTML width/height props
|
10
|
+
* or just output `width`, `height` or `width + "x" + height`
|
11
|
+
|
12
|
+
Samples:
|
13
|
+
|
14
|
+
```html
|
15
|
+
{% imagesize image:width %}
|
16
|
+
350
|
17
|
+
|
18
|
+
{% imagesize image:opengraph %}
|
19
|
+
<meta property='og:image:width' content='350'/><meta property='og:image:height' content='32'/>
|
20
|
+
|
21
|
+
{% imagesize image:img %}
|
22
|
+
<img src='/assets/logo.jpg' width='350' height='32'>
|
23
|
+
```
|
24
|
+
|
25
|
+
## Installation
|
26
|
+
|
27
|
+
Add this to your Gemfile:
|
28
|
+
|
29
|
+
```ruby
|
30
|
+
gem "jekyll-image-size"
|
31
|
+
```
|
32
|
+
|
33
|
+
Add this to your _config.yml:
|
34
|
+
|
35
|
+
```yaml
|
36
|
+
plugins:
|
37
|
+
- image-size
|
38
|
+
```
|
39
|
+
|
40
|
+
## File Types Supported
|
41
|
+
|
42
|
+
Jekyll-image-size uses the fastimage gem. It supports every type [fastimage](https://github.com/sdsykes/fastimage) support. As of right now, that means:
|
43
|
+
|
44
|
+
```
|
45
|
+
gif, jpeg, png, tiff, bmp, ico, cur, psd, svg, webp
|
46
|
+
```
|
47
|
+
|
48
|
+
|
49
|
+
## Usage
|
50
|
+
|
51
|
+
The `imagesize` takes one parameter. That parameter has the form:
|
52
|
+
|
53
|
+
```
|
54
|
+
source[:format[/divide-by-number]][ rest...]
|
55
|
+
```
|
56
|
+
|
57
|
+
source is a string and can be one of:
|
58
|
+
|
59
|
+
* url
|
60
|
+
* file (rooted in the project root)
|
61
|
+
* Liquid/Jekyll context-variable name
|
62
|
+
|
63
|
+
formats:
|
64
|
+
|
65
|
+
* size: `WxH`
|
66
|
+
* width: `W`
|
67
|
+
* height: `H`
|
68
|
+
* css: `width: Wpx; height: Hpx;`
|
69
|
+
* props: `width='W' height='H'`
|
70
|
+
* opengraph: `<meta property='og:image:width' content='W'/><meta property='og:image:height' content='H'/>`
|
71
|
+
* img: `<img src='/assets/logo.jpg' width='W' height='H'>`
|
72
|
+
|
73
|
+
divide-by-numbers:
|
74
|
+
|
75
|
+
* integer: 2
|
76
|
+
* float: 2.5 or 0.5 or .5
|
77
|
+
|
78
|
+
rest:
|
79
|
+
|
80
|
+
* must start with a space
|
81
|
+
* only used for the "img" tag format
|
82
|
+
* appended to the end of the img-tag just before the ">".
|
83
|
+
|
84
|
+
## Examples
|
85
|
+
|
86
|
+
Format examples:
|
87
|
+
|
88
|
+
```html
|
89
|
+
{% imagesize source %} >> 652x435
|
90
|
+
{% imagesize source:size %} >> 652x435
|
91
|
+
{% imagesize source:size/2 %} >> 326x218
|
92
|
+
{% imagesize source:width %} >> 652
|
93
|
+
{% imagesize source:height %} >> 435
|
94
|
+
{% imagesize source:css %} >> width: 652px; height: 435px;
|
95
|
+
{% imagesize source:props %} >> width='652' height='435'
|
96
|
+
{% imagesize source:opengraph %} >> <meta property='og:image:width' content='350'/><meta property='og:image:height' content='32'/>
|
97
|
+
{% imagesize source:img %} >> <img src='/assets/logo.jpg' width='350' height='32'>
|
98
|
+
```
|
99
|
+
|
100
|
+
Image source examples:
|
101
|
+
|
102
|
+
```html
|
103
|
+
{% imagesize /assets/logo.jpg %}
|
104
|
+
{% assign image = site.image %}
|
105
|
+
{% imagesize image %}
|
106
|
+
```
|
107
|
+
|
108
|
+
Combined examples:
|
109
|
+
|
110
|
+
```html
|
111
|
+
{% imagesize /assets/logo.jpg:opengraph %}
|
112
|
+
{% imagesize /assets/logo.jpg:css/2 %}
|
113
|
+
{% imagesize image:width/2.5 %}
|
114
|
+
{% imagesize /assets/logo.jpg:img alt='my alt string' %}
|
115
|
+
# <img src='/assets/logo.jpg' width='350' height='32' alt='my alt string'>
|
116
|
+
```
|
117
|
+
|
118
|
+
## License
|
119
|
+
|
120
|
+
jekyll-image-size is [MIT licensed](./LICENSE).
|
121
|
+
|
122
|
+
## Produced By
|
123
|
+
|
124
|
+
jekyll-image-size was produced at [GenUI.co](https://www.genui.co).
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
@@ -0,0 +1,25 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'jekyll-image-size/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "jekyll-image-size"
|
8
|
+
spec.version = Jekyll::ImageSize::VERSION
|
9
|
+
spec.authors = ["Shane Brinkman-Davis Delamore"]
|
10
|
+
spec.email = ["shane@genui.com"]
|
11
|
+
|
12
|
+
spec.summary = "jekyll tag plugin to insert the image-width and image-height of any static asset"
|
13
|
+
spec.description = "jekyll tag plugin to insert the image-width and image-height of any static asset"
|
14
|
+
spec.homepage = "https://github.com/shanebdavis/jekyll-image-size"
|
15
|
+
spec.license = "MIT"
|
16
|
+
|
17
|
+
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
18
|
+
spec.require_paths = ["lib"]
|
19
|
+
|
20
|
+
spec.add_dependency 'jekyll', '>= 3.7'
|
21
|
+
spec.add_dependency 'fastimage', '>= 1.8'
|
22
|
+
spec.add_development_dependency "bundler", "~> 2"
|
23
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
24
|
+
spec.add_development_dependency "rspec", "~> 3.0"
|
25
|
+
end
|
@@ -0,0 +1,72 @@
|
|
1
|
+
require "jekyll"
|
2
|
+
require 'fastimage'
|
3
|
+
require "jekyll-image-size/version"
|
4
|
+
|
5
|
+
class ImageSizeError < StandardError; end
|
6
|
+
|
7
|
+
# SEE https://github.com/Shopify/liquid/wiki/Liquid-for-Programmers
|
8
|
+
class ImageSizeTag < Liquid::Tag
|
9
|
+
|
10
|
+
def initialize(tagName, content, tokens)
|
11
|
+
super
|
12
|
+
@content = content.strip
|
13
|
+
@tokens = tokens
|
14
|
+
end
|
15
|
+
|
16
|
+
def self.getImageSize(content, context = nil)
|
17
|
+
if m = content.match(/^((?:[^:!]|:[^a-z])+)(?::([a-z]+)(?:\/((?:\d+|(?=\.))(?:\.\d+)?))?)?(\!)?( .*)?$/i)
|
18
|
+
source, mode, scale, required, rest = m.captures
|
19
|
+
|
20
|
+
else
|
21
|
+
raise ImageSizeError.new "invalid imagesize parameter: #{content}"
|
22
|
+
end
|
23
|
+
|
24
|
+
rawSource = source
|
25
|
+
|
26
|
+
source = source.sub(/^\//, '')
|
27
|
+
|
28
|
+
size = FastImage.size(source)
|
29
|
+
if context && !size
|
30
|
+
if contextSource = rawSource = context[source]
|
31
|
+
contextSource = contextSource.sub(/^\//, '')
|
32
|
+
size = FastImage.size(contextSource)
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
if size && size[0] > 0 && size[1] > 0
|
37
|
+
width, height = size
|
38
|
+
else
|
39
|
+
raise ImageSizeError.new "image file not found: #{source}" if required
|
40
|
+
width = height = 0
|
41
|
+
end
|
42
|
+
|
43
|
+
if scale
|
44
|
+
scale = scale.to_f
|
45
|
+
width = (width / scale).round
|
46
|
+
height = (height / scale).round
|
47
|
+
end
|
48
|
+
|
49
|
+
case if mode then mode.downcase else nil end
|
50
|
+
when "opengraph"
|
51
|
+
if size then "<meta property='og:image:width' content='#{width}'/><meta property='og:image:height' content='#{height}'/>"
|
52
|
+
else "" end
|
53
|
+
|
54
|
+
when "img" then
|
55
|
+
if size then "<img src='#{rawSource}' width='#{width}' height='#{height}'#{rest}>"
|
56
|
+
else "" end
|
57
|
+
|
58
|
+
when "width" then width.to_s
|
59
|
+
when "height" then height.to_s
|
60
|
+
when "css" then if size then "width: #{width}px; height: #{height}px;" else "" end
|
61
|
+
when "props" then if size then "width='#{width}' height='#{height}'" else "" end
|
62
|
+
when "size", nil then "#{width}x#{height}"
|
63
|
+
else raise ImageSizeError.new "invalid imagesize mode: #{mode}"
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
def render(context)
|
68
|
+
ImageSizeTag.getImageSize @content, context
|
69
|
+
end
|
70
|
+
|
71
|
+
Liquid::Template.register_tag "imagesize", self
|
72
|
+
end
|
metadata
ADDED
@@ -0,0 +1,127 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: jekyll-image-size
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.3.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Shane Brinkman-Davis Delamore
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2019-08-01 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: jekyll
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '3.7'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '3.7'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: fastimage
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '1.8'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '1.8'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: bundler
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '2'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '2'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rake
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '10.0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '10.0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: rspec
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '3.0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '3.0'
|
83
|
+
description: jekyll tag plugin to insert the image-width and image-height of any static
|
84
|
+
asset
|
85
|
+
email:
|
86
|
+
- shane@genui.com
|
87
|
+
executables: []
|
88
|
+
extensions: []
|
89
|
+
extra_rdoc_files: []
|
90
|
+
files:
|
91
|
+
- ".gitignore"
|
92
|
+
- ".rspec"
|
93
|
+
- ".travis.yml"
|
94
|
+
- Gemfile
|
95
|
+
- Gemfile.lock
|
96
|
+
- LICENSE
|
97
|
+
- README.md
|
98
|
+
- Rakefile
|
99
|
+
- jekyll-image-size.gemspec
|
100
|
+
- lib/jekyll-image-size.rb
|
101
|
+
- lib/jekyll-image-size/version.rb
|
102
|
+
homepage: https://github.com/shanebdavis/jekyll-image-size
|
103
|
+
licenses:
|
104
|
+
- MIT
|
105
|
+
metadata: {}
|
106
|
+
post_install_message:
|
107
|
+
rdoc_options: []
|
108
|
+
require_paths:
|
109
|
+
- lib
|
110
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
111
|
+
requirements:
|
112
|
+
- - ">="
|
113
|
+
- !ruby/object:Gem::Version
|
114
|
+
version: '0'
|
115
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
116
|
+
requirements:
|
117
|
+
- - ">="
|
118
|
+
- !ruby/object:Gem::Version
|
119
|
+
version: '0'
|
120
|
+
requirements: []
|
121
|
+
rubyforge_project:
|
122
|
+
rubygems_version: 2.5.2.3
|
123
|
+
signing_key:
|
124
|
+
specification_version: 4
|
125
|
+
summary: jekyll tag plugin to insert the image-width and image-height of any static
|
126
|
+
asset
|
127
|
+
test_files: []
|