kamifusen 1.3 → 1.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/app/views/kamifusen/_view.html.erb +34 -6
- data/lib/kamifusen/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 21b6ef8996df081487d71d6a914c245ab3fedb803a775ed1b4c10384b3f5a1df
|
4
|
+
data.tar.gz: 9e481700b2654d2bafae6cf79f6f4b44b7d4445407075283b7a2bd9a01200aea
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fad6e4138146acb5e5afc4ad9b9522aad4179fecdd97dd97f822fcacac49eb8dcceaed6fde41ff09f397d8aa074f7366f28175fb3e26d62acc7fb7126065ff2a
|
7
|
+
data.tar.gz: ea01b9e4e5ca7d82e9e26f51907a62609a6c1edfcf994735031cd576810bdec80c23785b881609c3eaffecdb23d91d86b4ac7269305015093a5d3e9cc8364601
|
data/Gemfile.lock
CHANGED
@@ -2,17 +2,45 @@
|
|
2
2
|
# image_tag options
|
3
3
|
options ||= {}
|
4
4
|
alt = options[:alt]
|
5
|
-
width = options[:width]
|
6
|
-
height = options[:height]
|
7
5
|
klass = options[:class]
|
8
6
|
picture_class = options[:picture_class]
|
7
|
+
width = options[:width]
|
8
|
+
height = options[:height]
|
9
|
+
if source&.metadata &&
|
10
|
+
source.metadata['analyzed'] &&
|
11
|
+
source.metadata.has_key?('width') &&
|
12
|
+
source.metadata.has_key?('height')
|
13
|
+
image_width = source.metadata['width']
|
14
|
+
image_height = source.metadata['height']
|
15
|
+
image_ratio = 1.0 * image_width / image_height
|
16
|
+
if width.nil? && height.nil?
|
17
|
+
# Prendre width et height réelles de l'image
|
18
|
+
width = image_width
|
19
|
+
height = image_height
|
20
|
+
elsif width.nil?
|
21
|
+
# Calculer la height sur ratio
|
22
|
+
width = height * image_ratio
|
23
|
+
elsif height.nil?
|
24
|
+
# Calcule la width sur ratio
|
25
|
+
height = width / image_ratio
|
26
|
+
else
|
27
|
+
# Width et height sont explicites,
|
28
|
+
# si le ratio demandé n'est pas celui de l'image,
|
29
|
+
# Redéfinir la height
|
30
|
+
width = [image_width, width].min
|
31
|
+
height = width / image_ratio
|
32
|
+
end
|
33
|
+
width = width.round
|
34
|
+
height = height.round
|
35
|
+
end
|
9
36
|
parameters = " loading=\"lazy\" decoding=\"async\""
|
10
|
-
parameters += " alt=\"#{
|
11
|
-
parameters += " width=\"#{
|
12
|
-
parameters += " height=\"#{
|
13
|
-
parameters += " class=\"#{
|
37
|
+
parameters += " alt=\"#{ alt }\"" if alt
|
38
|
+
parameters += " width=\"#{ width }\"" if width
|
39
|
+
parameters += " height=\"#{ height }\"" if height
|
40
|
+
parameters += " class=\"#{ klass }\"" if klass
|
14
41
|
%>
|
15
42
|
<% if source.variable? %>
|
43
|
+
<%#= "#{image_width} x #{image_height}, #{image_ratio} ratio => #{width} x #{height}<br>".html_safe %>
|
16
44
|
<%
|
17
45
|
# kamifusen settings
|
18
46
|
sizes = [320, 576, 640, 768, 992, 1152, 1200, 1400, 1536, 1984, 2400]
|
data/lib/kamifusen/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: kamifusen
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: '1.
|
4
|
+
version: '1.4'
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sébastien Moulène
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: exe
|
11
11
|
cert_chain: []
|
12
|
-
date: 2021-07-
|
12
|
+
date: 2021-07-07 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rails
|