dynamic_image 2.0.13 → 2.0.14
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/dynamic_image/belongs_to.rb +1 -1
- data/lib/dynamic_image/helper.rb +8 -1
- data/lib/dynamic_image/version.rb +1 -1
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 20c84bf7939b0450acb161b046d8c42e5f3c8e12
|
4
|
+
data.tar.gz: '09367ca2c355b0d54180247e87bf9d72dd38c02c'
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f2ab39cadc60f5ffd21e3ecb017a77f2ccc2442427c97efb10acdc62d19c30f0c4793fc3460e283337bc02fce92cbdb14a1125dcef75e0cc34b38b3aec0553b9
|
7
|
+
data.tar.gz: 7d2b3816a103a1f76079326ed4aa90b2e9eb43ee4a7803c1bb8b1b4825ac0e64a0d7f3feac616f3a2dfa72703a8ace2ed5fc16f71b19f771d83b5332991fa6ae
|
@@ -7,7 +7,7 @@ module DynamicImage
|
|
7
7
|
extend ActiveSupport::Concern
|
8
8
|
|
9
9
|
module ClassMethods
|
10
|
-
def belongs_to_image(name, scope = nil, options
|
10
|
+
def belongs_to_image(name, scope = nil, **options)
|
11
11
|
belongs_to(name, scope, options)
|
12
12
|
|
13
13
|
define_method "#{name}=" do |new_image|
|
data/lib/dynamic_image/helper.rb
CHANGED
@@ -31,7 +31,7 @@ module DynamicImage
|
|
31
31
|
# # => <img alt="Avatar" height="62" src="..." width="100" />
|
32
32
|
def dynamic_image_tag(record_or_array, options = {})
|
33
33
|
record = extract_dynamic_image_record(record_or_array)
|
34
|
-
options = { alt:
|
34
|
+
options = { alt: filename_to_alt(record.filename) }.merge(options)
|
35
35
|
|
36
36
|
size = fit_size!(record_or_array, options)
|
37
37
|
url_options = options.extract!(*allowed_dynamic_image_url_options)
|
@@ -161,6 +161,13 @@ module DynamicImage
|
|
161
161
|
end
|
162
162
|
end
|
163
163
|
|
164
|
+
def filename_to_alt(str)
|
165
|
+
File.basename(str, ".*".freeze)
|
166
|
+
.sub(/-[[:xdigit:]]{32,64}\z/, "".freeze)
|
167
|
+
.tr("-_".freeze, " ".freeze)
|
168
|
+
.capitalize
|
169
|
+
end
|
170
|
+
|
164
171
|
def fit_size!(record_or_array, options)
|
165
172
|
record = extract_dynamic_image_record(record_or_array)
|
166
173
|
action = options[:action].try(:to_s)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dynamic_image
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.0.
|
4
|
+
version: 2.0.14
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Inge Jørgensen
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-05-
|
11
|
+
date: 2018-05-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -98,14 +98,14 @@ dependencies:
|
|
98
98
|
requirements:
|
99
99
|
- - "~>"
|
100
100
|
- !ruby/object:Gem::Version
|
101
|
-
version: 3.
|
101
|
+
version: 3.7.0
|
102
102
|
type: :development
|
103
103
|
prerelease: false
|
104
104
|
version_requirements: !ruby/object:Gem::Requirement
|
105
105
|
requirements:
|
106
106
|
- - "~>"
|
107
107
|
- !ruby/object:Gem::Version
|
108
|
-
version: 3.
|
108
|
+
version: 3.7.0
|
109
109
|
description: DynamicImage is a Rails plugin that simplifies image uploading and processing
|
110
110
|
email:
|
111
111
|
- inge@elektronaut.no
|