jekyll-responsive_image 0.9.0 → 0.9.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 +4 -4
- data/.gitignore +1 -0
- data/README.md +35 -8
- data/Rakefile +1 -1
- data/features/fixtures/_includes/custom-template.html +1 -0
- data/features/fixtures/_includes/responsive-image.html +1 -1
- data/features/responsive-image.feature +30 -3
- data/features/support/env.rb +3 -4
- data/lib/jekyll/responsive_image.rb +2 -1
- data/lib/jekyll/responsive_image/version.rb +1 -1
- metadata +2 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: dc0a20c9cc1f1bfd10aef481ca55672377b9379f
|
4
|
+
data.tar.gz: 60044f0efde1042917c727817d597e11e38ca40a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2c21adf98bc2bd32e379bb7721f7ff2ce9149f2a351dd00f99ead6f52b935ae82a30ce1d62fb76abbef567c5d0ad701e36ffc31617bef6b609ce316ae6c23d1d
|
7
|
+
data.tar.gz: fb4cd91b2570b517e2e05662e1117adce75616b973a48faf6147e3f4ecc802be260e81e7e74a49b4be166025160c826cf3a4a6f7d1ea3dbe29519dd4419a5bc4
|
data/.gitignore
CHANGED
data/README.md
CHANGED
@@ -8,18 +8,19 @@ Jekyll Responsive Images is a [Jekyll](http://jekyllrb.com/) plugin and utility
|
|
8
8
|
|
9
9
|
## Installation
|
10
10
|
|
11
|
-
|
11
|
+
You can either use the gem and update your `_config.yml`:
|
12
12
|
|
13
13
|
```
|
14
14
|
$ gem install jekyll-responsive_image
|
15
15
|
```
|
16
16
|
|
17
|
-
Or simply add it to your Jekyll `_config.yml`:
|
18
|
-
|
19
17
|
```yaml
|
18
|
+
# _config.yml
|
20
19
|
gems: [jekyll-responsive_image]
|
21
20
|
```
|
22
21
|
|
22
|
+
Or you can simply copy [`responsive_image.rb`](lib/jekyll/responsive_image.rb) into your `_plugins` directory.
|
23
|
+
|
23
24
|
## Configuration
|
24
25
|
|
25
26
|
An example configuration is below.
|
@@ -33,30 +34,38 @@ responsive_image:
|
|
33
34
|
sizes:
|
34
35
|
- width: 480 # How wide the resized image will be. Required
|
35
36
|
- width: 800
|
36
|
-
quality: 90 # JPEG quality. Optional.
|
37
|
+
quality: 90 # Override JPEG quality (default is 85). Optional.
|
37
38
|
- width: 1400
|
38
39
|
```
|
39
40
|
|
40
41
|
## Usage
|
41
42
|
|
42
|
-
Replace your images with the `responsive_image` tag, specifying
|
43
|
+
Replace your images with the `responsive_image` tag, specifying the path to the image in the `path` attribute.
|
43
44
|
|
44
45
|
```
|
45
46
|
{% responsive_image path: assets/my-file.jpg %}
|
46
47
|
```
|
47
48
|
|
48
|
-
|
49
|
+
You can override the template on a per-image basis by specifying the `template` attribute.
|
50
|
+
|
51
|
+
```
|
52
|
+
{% responsive_image path: assets/my-file.jpg template: _includes/another-template.html %}
|
53
|
+
```
|
54
|
+
|
55
|
+
Any extra attributes will be passed straight to the template as variables.
|
49
56
|
|
50
57
|
```
|
51
58
|
{% responsive_image path: assets/image.jpg alt: "Lorem ipsum..." title: "Lorem ipsum..." %}
|
52
59
|
```
|
53
60
|
|
54
|
-
|
61
|
+
### Template
|
62
|
+
|
63
|
+
You will need to create a template in order to use the `responsive_image` tag. A sample template is below.
|
55
64
|
|
56
65
|
```html
|
57
66
|
<img src="/{{ path }}"
|
58
67
|
alt="{{ alt }}"
|
59
|
-
title="{{ title }}
|
68
|
+
title="{{ title }}"
|
60
69
|
|
61
70
|
{% if resized %}
|
62
71
|
srcset="{% for i in resized %}
|
@@ -65,3 +74,21 @@ Create a template to suit your needs. A basic template example is below.
|
|
65
74
|
{% endif %}
|
66
75
|
>
|
67
76
|
```
|
77
|
+
|
78
|
+
#### Template Variables
|
79
|
+
|
80
|
+
The following variables are available in the template:
|
81
|
+
|
82
|
+
| Variable | Type | Description |
|
83
|
+
|-----------|--------|------------------------------------------------------------------------------------------------------|
|
84
|
+
| `path` | String | The path of the unmodified image. This is always the same as the `path` attribute passed to the tag. |
|
85
|
+
| `resized` | Array | An array of all the resized images. Each image contains the properties listed below. |
|
86
|
+
| `*` | String | Any other attributes will be passed to the template verbatim as strings. |
|
87
|
+
|
88
|
+
Each element in the `resized` array contains the following properties:
|
89
|
+
|
90
|
+
| Variable | Type | Description |
|
91
|
+
|----------|----------|----------------------------------|
|
92
|
+
| `path` | String | The path of the resized image. |
|
93
|
+
| `width` | Integer | The width of the resized image. |
|
94
|
+
| `height` | Integer | The height of the resized image. |
|
data/Rakefile
CHANGED
@@ -22,7 +22,7 @@ task :default => [:features]
|
|
22
22
|
|
23
23
|
task :release do |t|
|
24
24
|
system "gem build jekyll-responsive_image.gemspec"
|
25
|
-
system "git tag v#{Jekyll::ResponsiveImage::VERSION}"
|
25
|
+
system "git tag v#{Jekyll::ResponsiveImage::VERSION} -a -m 'Tagged release of jekyll-responsive_image-#{Jekyll::ResponsiveImage::VERSION}.gem'"
|
26
26
|
system "git push --tags"
|
27
27
|
system "gem push jekyll-responsive_image-#{Jekyll::ResponsiveImage::VERSION}.gem"
|
28
28
|
end
|
@@ -0,0 +1 @@
|
|
1
|
+
{{ resized | map: 'width' }}
|
@@ -13,9 +13,21 @@ Feature: Jekyll responsive-image tag
|
|
13
13
|
{% responsive_image path: assets/test.png alt: Foobar %}
|
14
14
|
"""
|
15
15
|
When I run Jekyll
|
16
|
-
Then I should see "<img alt=\"Foobar\" src=\"/assets/test.png\"
|
16
|
+
Then I should see "<img alt=\"Foobar\" src=\"/assets/test.png\"" in "_site/index.html"
|
17
17
|
|
18
|
-
Scenario:
|
18
|
+
Scenario: Adding custom attributes
|
19
|
+
Given I have a responsive_image configuration with:
|
20
|
+
"""
|
21
|
+
template: _includes/responsive-image.html
|
22
|
+
"""
|
23
|
+
And I have a file "index.html" with:
|
24
|
+
"""
|
25
|
+
{% responsive_image path: assets/test.png alt: Foobar title: "Lorem Ipsum" %}
|
26
|
+
"""
|
27
|
+
When I run Jekyll
|
28
|
+
Then I should see "<img alt=\"Foobar\" src=\"/assets/test.png\" title=\"Lorem Ipsum\"" in "_site/index.html"
|
29
|
+
|
30
|
+
Scenario: UTF-8 attributes
|
19
31
|
Given I have a responsive_image configuration with:
|
20
32
|
"""
|
21
33
|
template: _includes/responsive-image.html
|
@@ -25,7 +37,7 @@ Feature: Jekyll responsive-image tag
|
|
25
37
|
{% responsive_image path: assets/test.png alt: "かっこいい! ジェケルが好きです!" %}
|
26
38
|
"""
|
27
39
|
When I run Jekyll
|
28
|
-
Then I should see "<img alt=\"かっこいい! ジェケルが好きです!\" src=\"/assets/test.png\"
|
40
|
+
Then I should see "<img alt=\"かっこいい! ジェケルが好きです!\" src=\"/assets/test.png\"" in "_site/index.html"
|
29
41
|
|
30
42
|
Scenario: Image with multiple sizes
|
31
43
|
Given I have a responsive_image configuration with:
|
@@ -45,3 +57,18 @@ Feature: Jekyll responsive-image tag
|
|
45
57
|
And I should see "/assets/resized/test-200x100.png 200w" in "_site/index.html"
|
46
58
|
And the file "assets/resized/test-100x50.png" should exist
|
47
59
|
And the file "assets/resized/test-200x100.png" should exist
|
60
|
+
|
61
|
+
Scenario: Overriding the template
|
62
|
+
Given I have a responsive_image configuration with:
|
63
|
+
"""
|
64
|
+
template: _includes/responsive-image.html
|
65
|
+
sizes:
|
66
|
+
- width: 100
|
67
|
+
- width: 200
|
68
|
+
"""
|
69
|
+
And I have a file "index.html" with:
|
70
|
+
"""
|
71
|
+
{% responsive_image path: assets/test.png template: _includes/custom-template.html %}
|
72
|
+
"""
|
73
|
+
When I run Jekyll
|
74
|
+
Then I should see "100200" in "_site/index.html"
|
data/features/support/env.rb
CHANGED
@@ -86,9 +86,10 @@ module Jekyll
|
|
86
86
|
config['output_dir'] ||= 'assets/resized'
|
87
87
|
config['sizes'] ||= []
|
88
88
|
|
89
|
+
@attributes['template'] ||= config['template']
|
89
90
|
@attributes['resized'] = resize_image(@attributes['path'], config)
|
90
91
|
|
91
|
-
partial = File.read(
|
92
|
+
partial = File.read(@attributes['template'])
|
92
93
|
template = Liquid::Template.parse(partial)
|
93
94
|
|
94
95
|
template.render!(@attributes)
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: jekyll-responsive_image
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.9.
|
4
|
+
version: 0.9.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Joseph Wynn
|
@@ -54,6 +54,7 @@ files:
|
|
54
54
|
- LICENSE
|
55
55
|
- README.md
|
56
56
|
- Rakefile
|
57
|
+
- features/fixtures/_includes/custom-template.html
|
57
58
|
- features/fixtures/_includes/responsive-image.html
|
58
59
|
- features/fixtures/assets/test.png
|
59
60
|
- features/responsive-image.feature
|