front_man 0.1.2 → 0.2.0
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/README.md +21 -5
- data/app/helpers/front_man/images_helper.rb +25 -1
- data/lib/front_man/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ef98b19bdac619ba344b5b35818dc457f8fc690d
|
4
|
+
data.tar.gz: 6b0c61e6c4e61f3b23408ba540c819704d5823a8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8d1f92763814671313be2f697a17544b2cc09528ac3054f1d601133faea92e01a6ad397c777c160ecb37bbd1d7f116aafd007e4aefde598b9ff50d2e6fa4d2a7
|
7
|
+
data.tar.gz: 4733b4462fe61a80a59382826e19cf1825b7d081bfc635b41a4745ab4d0ad04b48391cc40d95fafcbd70aa97ffe44f8cf09721b9ae960659c0dc48375406df81
|
data/README.md
CHANGED
@@ -90,13 +90,29 @@ Used to set `srcset` attribute on `img` tag.
|
|
90
90
|
Example:
|
91
91
|
|
92
92
|
```ruby
|
93
|
-
image_set_tag(
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
93
|
+
image_set_tag('http://placehold.it/1200x600',
|
94
|
+
srcset: {
|
95
|
+
'http://placehold.it/300x150' => '300w',
|
96
|
+
'http://placehold.it/600x300' => '600w',
|
97
|
+
'http://placehold.it/1200x600' => '1200w'
|
98
|
+
}
|
99
|
+
)
|
98
100
|
```
|
99
101
|
|
102
|
+
If you would like to support lazy loading, in conjunction with [lazySizes](https://github.com/aFarkas/lazysizes), you just need to add the class `lazyload` as follows:
|
103
|
+
|
104
|
+
```ruby
|
105
|
+
image_set_tag('http://placehold.it/1200x600',
|
106
|
+
srcset: {
|
107
|
+
'http://placehold.it/300x150' => '300w',
|
108
|
+
'http://placehold.it/600x300' => '600w',
|
109
|
+
'http://placehold.it/1200x600' => '1200w'
|
110
|
+
},
|
111
|
+
class: 'lazyload'
|
112
|
+
)
|
113
|
+
```
|
114
|
+
N.B. You would need to ensure the lazySizes script is installed for this to work
|
115
|
+
|
100
116
|
## Kudos
|
101
117
|
|
102
118
|
The conventions laid out in the asset files here were based upon those discussed in the article below. Kudos to [@fat](https://github.com/fat).
|
@@ -26,8 +26,15 @@ module FrontMan
|
|
26
26
|
srcset = srcset.join(', ')
|
27
27
|
|
28
28
|
if options[:class].present? && options[:class].match(/\blazyload\b/)
|
29
|
+
options = options.dup
|
29
30
|
options.delete(:srcset)
|
30
|
-
options[:
|
31
|
+
src = options[:src] || image_path(filename)
|
32
|
+
options.delete(:src)
|
33
|
+
options[:data] ||= {}
|
34
|
+
options[:data] = { sizes: 'auto', src: src, srcset: srcset }
|
35
|
+
.merge(options[:data])
|
36
|
+
|
37
|
+
return no_src_image_tag(filename, options)
|
31
38
|
else
|
32
39
|
options[:srcset] = srcset
|
33
40
|
end
|
@@ -35,5 +42,22 @@ module FrontMan
|
|
35
42
|
|
36
43
|
image_tag(filename, options)
|
37
44
|
end
|
45
|
+
|
46
|
+
private
|
47
|
+
|
48
|
+
# extracted and modified from
|
49
|
+
# https://github.com/rails/rails/blob/878e42916db8a18f61333f315907480d7c48c040/actionview/lib/action_view/helpers/asset_tag_helper.rb#L208
|
50
|
+
def no_src_image_tag(source, options)
|
51
|
+
options = options.symbolize_keys
|
52
|
+
|
53
|
+
src = path_to_image(source)
|
54
|
+
|
55
|
+
unless src =~ /^(?:cid|data):/ || src.blank?
|
56
|
+
options[:alt] = options.fetch(:alt){ image_alt(src) }
|
57
|
+
end
|
58
|
+
|
59
|
+
options[:width], options[:height] = extract_dimensions(options.delete(:size)) if options[:size]
|
60
|
+
tag("img", options)
|
61
|
+
end
|
38
62
|
end
|
39
63
|
end
|
data/lib/front_man/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: front_man
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Viktor Fonic
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: exe
|
11
11
|
cert_chain: []
|
12
|
-
date: 2016-
|
12
|
+
date: 2016-03-22 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: activesupport
|