middleman-dragonfly_thumbnailer 1.0.2 → 1.1.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
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: f96776dc93da5d1a775e45b604c8fb5e8a611c4912e2f22bc59ab241d6e639d3
|
4
|
+
data.tar.gz: 9e7fe35a6ea838cb7e2a3365b19644f84633d091842cbc544003f99cb4695088
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 076b3ef978712deca27292e7ce558970b3628173c8dddce08729852cbdcb1b6939b25465aabb452de2de8f5689cc0f4ecf4be2c996bc09a926cb13c640c4c41c
|
7
|
+
data.tar.gz: 6f5dd8221b1cdae51bd8af6f5a545aff70fcf883f82484c3970294807c15ba73edbe781c7de0e964fea8d9d1abac3e6cb202efe1e1620b053ae74c08efbf8b6f
|
data/README.md
CHANGED
@@ -25,12 +25,13 @@ Just add the following to your config.rb file:
|
|
25
25
|
## Usage
|
26
26
|
|
27
27
|
<%= thumb_tag 'image.png', '100x100#', class: 'thumbnail' %>
|
28
|
+
<%= thumb_tag 'image.gif', '100x100#', format: 'jpg', frame: 1, class: 'thumbnail' %>
|
28
29
|
|
29
|
-
The second argument is a geometry string which specifies the dimensions and options such as aspect ratio and cropping. Have a look at
|
30
|
+
The second argument is a geometry string which specifies the dimensions and options such as aspect ratio and cropping. You can also change the output format and choose the frame for GIFs. Have a look at https://markevans.github.io/dragonfly/imagemagick for examples of what you can do. Any other options will be passed to the image_tag helper.
|
30
31
|
|
31
32
|
When running Middleman in development, thumbnails will be generated on the fly and encoded in data URLs.
|
32
33
|
|
33
|
-
During a build, the thumbnails will be saved next to original image in a sub directory named
|
34
|
+
During a build, the thumbnails will be saved next to original image in a sub directory named using the geometry string, so the thumbnail for `images/image.png` will be saved as `images/100x100/image.png`.
|
34
35
|
|
35
36
|
## Contributing
|
36
37
|
|
@@ -42,4 +43,4 @@ During a build, the thumbnails will be saved next to original image in a sub dir
|
|
42
43
|
|
43
44
|
## License
|
44
45
|
|
45
|
-
Copyright (c)
|
46
|
+
Copyright (c) 2018 Andrew White. MIT Licensed, see LICENSE.txt for details.
|
@@ -1,13 +1,11 @@
|
|
1
|
+
require 'middleman-core/logger'
|
1
2
|
require 'dragonfly'
|
2
3
|
|
3
4
|
module Middleman
|
4
5
|
module DragonflyThumbnailer
|
5
6
|
class Extension < Middleman::Extension
|
6
|
-
attr_accessor :images
|
7
|
-
|
8
7
|
def initialize(app, options_hash = {}, &block)
|
9
8
|
super
|
10
|
-
@images = []
|
11
9
|
configure_dragonfly
|
12
10
|
end
|
13
11
|
|
@@ -26,38 +24,54 @@ module Middleman
|
|
26
24
|
build_path(image))
|
27
25
|
end
|
28
26
|
|
29
|
-
def thumb(path, geometry)
|
27
|
+
def thumb(path, geometry, image_options = {})
|
30
28
|
absolute_path = absolute_source_path path
|
31
29
|
return unless File.exist?(absolute_path)
|
32
30
|
|
33
31
|
image = ::Dragonfly.app.fetch_file(absolute_path)
|
34
32
|
image.meta['original_path'] = path
|
35
33
|
image.meta['geometry'] = geometry
|
36
|
-
image = image.thumb(geometry)
|
37
|
-
images << image
|
38
|
-
image
|
39
|
-
end
|
34
|
+
image = image.thumb(geometry, image_options)
|
40
35
|
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
image.
|
36
|
+
if app.build?
|
37
|
+
persist_file(image)
|
38
|
+
build_path(image)
|
39
|
+
else
|
40
|
+
image.b64_data
|
46
41
|
end
|
47
42
|
end
|
48
43
|
|
44
|
+
def extract_image_options(options)
|
45
|
+
image_options = {
|
46
|
+
'format' => options.delete(:format),
|
47
|
+
'frame' => options.delete(:frame)
|
48
|
+
}.delete_if { |_k, v| v.nil? }
|
49
|
+
|
50
|
+
return options, image_options
|
51
|
+
end
|
52
|
+
|
53
|
+
def persist_file(image)
|
54
|
+
path = absolute_build_path(image)
|
55
|
+
image.to_file(path).close
|
56
|
+
end
|
57
|
+
|
49
58
|
helpers do
|
50
59
|
def thumb_tag(path, geometry, options = {})
|
51
|
-
|
52
|
-
|
60
|
+
extension = extensions[:dragonfly_thumbnailer]
|
61
|
+
|
62
|
+
options, image_options = extension.extract_image_options(options)
|
63
|
+
url = extension.thumb(path, geometry, image_options)
|
64
|
+
|
65
|
+
image_tag(url, options) if url
|
66
|
+
end
|
67
|
+
|
68
|
+
def thumb_path(path, geometry, options = {})
|
69
|
+
extension = extensions[:dragonfly_thumbnailer]
|
53
70
|
|
54
|
-
|
55
|
-
|
56
|
-
else
|
57
|
-
url = extensions[:dragonfly_thumbnailer].build_path(image)
|
58
|
-
end
|
71
|
+
_options, image_options = extension.extract_image_options(options)
|
72
|
+
url = extension.thumb(path, geometry, image_options)
|
59
73
|
|
60
|
-
|
74
|
+
image_path(url) if url
|
61
75
|
end
|
62
76
|
end
|
63
77
|
|
@@ -7,7 +7,6 @@ Gem::Specification.new do |spec|
|
|
7
7
|
spec.name = 'middleman-dragonfly_thumbnailer'
|
8
8
|
spec.version = Middleman::DragonflyThumbnailer::VERSION
|
9
9
|
spec.authors = ['Andrew White']
|
10
|
-
spec.email = ['andrew@vohm.com']
|
11
10
|
spec.summary = 'Thumbnail generation with Dragonfly'
|
12
11
|
spec.description = "Middleman Dragonfly Thumbnailer is a Middleman extension that lets you easily create thumbnails using Dragonfly's thumb processor."
|
13
12
|
spec.homepage = 'https://github.com/scarypine/middleman-dragonfly_thumbnailer'
|
@@ -21,6 +20,6 @@ Gem::Specification.new do |spec|
|
|
21
20
|
spec.add_development_dependency 'bundler', '~> 1.6'
|
22
21
|
spec.add_development_dependency 'rake'
|
23
22
|
|
24
|
-
spec.add_runtime_dependency('middleman-core', ['
|
23
|
+
spec.add_runtime_dependency('middleman-core', ['>= 3.2'])
|
25
24
|
spec.add_runtime_dependency('dragonfly', ['>= 1.0.0'])
|
26
25
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: middleman-dragonfly_thumbnailer
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0
|
4
|
+
version: 1.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andrew White
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2018-11-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -42,14 +42,14 @@ dependencies:
|
|
42
42
|
name: middleman-core
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
|
-
- - "
|
45
|
+
- - ">="
|
46
46
|
- !ruby/object:Gem::Version
|
47
47
|
version: '3.2'
|
48
48
|
type: :runtime
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
|
-
- - "
|
52
|
+
- - ">="
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '3.2'
|
55
55
|
- !ruby/object:Gem::Dependency
|
@@ -68,8 +68,7 @@ dependencies:
|
|
68
68
|
version: 1.0.0
|
69
69
|
description: Middleman Dragonfly Thumbnailer is a Middleman extension that lets you
|
70
70
|
easily create thumbnails using Dragonfly's thumb processor.
|
71
|
-
email:
|
72
|
-
- andrew@vohm.com
|
71
|
+
email:
|
73
72
|
executables: []
|
74
73
|
extensions: []
|
75
74
|
extra_rdoc_files: []
|
@@ -103,7 +102,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
103
102
|
version: '0'
|
104
103
|
requirements: []
|
105
104
|
rubyforge_project:
|
106
|
-
rubygems_version: 2.
|
105
|
+
rubygems_version: 2.7.6
|
107
106
|
signing_key:
|
108
107
|
specification_version: 4
|
109
108
|
summary: Thumbnail generation with Dragonfly
|