obf 0.6.22 → 0.6.23
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/obf/external.rb +16 -1
- data/lib/obf/utils.rb +4 -4
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4ce715d0852c7bb87bb8584ea041a8c5d24f403d
|
4
|
+
data.tar.gz: 103949c6a331ba5ad318fea97fc8d680499776fc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b6c190232522bd729c0aa578b85726db245e29369f835af659f7cb66d3dc3900c064b11ef3f8f9172f38e04d477552a4fdb01063dd140608ddb8c7262a4a9cb5
|
7
|
+
data.tar.gz: fe1fcea209a1be6f2e652ff77258481bb14410fd146f8fed9770c1d63cf0101848c49b26f2a8cac14db6b042b2b81791856db1359c6c2ba9962adc699c675622
|
data/lib/obf/external.rb
CHANGED
@@ -98,19 +98,34 @@ module OBF::External
|
|
98
98
|
}
|
99
99
|
if !path_hash
|
100
100
|
image['data'] ||= OBF::Utils.image_base64(image['url']) if image['url']
|
101
|
+
if image['data'] && (!image['content_type'] || !image['width'] || !image['height'])
|
102
|
+
attrs = OBF::Utils.image_attrs(image['data'])
|
103
|
+
image['content_type'] ||= attrs['content_type']
|
104
|
+
image['width'] ||= attrs['width']
|
105
|
+
image['height'] ||= attrs['height']
|
106
|
+
end
|
101
107
|
else
|
102
108
|
if path_hash['images'] && path_hash['images'][image['id']]
|
103
109
|
image['path'] = path_hash['images'][image['id']]['path']
|
110
|
+
image['content_type'] ||= path_hash['images'][image['id']]['content_type']
|
111
|
+
image['width'] ||= path_hash['images'][image['id']]['width']
|
112
|
+
image['height'] ||= path_hash['images'][image['id']]['height']
|
104
113
|
else
|
105
114
|
image_fetch = OBF::Utils.image_raw(image['url'] || image['data'])
|
106
115
|
if image_fetch
|
107
116
|
zip_path = "images/image_#{image['id']}#{image_fetch['extension']}"
|
108
117
|
path_hash['images'] ||= {}
|
109
118
|
path_hash['images'][image['id']] = {
|
110
|
-
'path' => zip_path
|
119
|
+
'path' => zip_path,
|
120
|
+
'content_type' => image_fetch['content_type'],
|
121
|
+
'width' => image_fetch['width'],
|
122
|
+
'height' => image_fetch['height']
|
111
123
|
}
|
112
124
|
path_hash['zip'].add(zip_path, image_fetch['data'])
|
113
125
|
image['path'] = zip_path
|
126
|
+
image['content_type'] ||= image_fetch['content_type']
|
127
|
+
image['width'] ||= image_fetch['width']
|
128
|
+
image['height'] ||= image_fetch['height']
|
114
129
|
end
|
115
130
|
end
|
116
131
|
end
|
data/lib/obf/utils.rb
CHANGED
@@ -110,10 +110,10 @@ module OBF::Utils
|
|
110
110
|
'data' => File.read(url),
|
111
111
|
'content_type' => types[0] && types[0].to_s
|
112
112
|
}
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
113
|
+
if !image['content_type']
|
114
|
+
attrs = image_attrs(url)
|
115
|
+
image['content_type'] ||= attrs['content_type']
|
116
|
+
end
|
117
117
|
end
|
118
118
|
return nil unless image
|
119
119
|
str = "data:" + image['content_type']
|