kamifusen 1.3 → 1.4

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: eac96058e579f9ae629576bd126de9042b25ab3faffc7b99dfa875944d576239
4
- data.tar.gz: e8480cdec01a138f28b8a725492b99a50d41c1ae107e59c4e41544bf61b4b1d5
3
+ metadata.gz: 21b6ef8996df081487d71d6a914c245ab3fedb803a775ed1b4c10384b3f5a1df
4
+ data.tar.gz: 9e481700b2654d2bafae6cf79f6f4b44b7d4445407075283b7a2bd9a01200aea
5
5
  SHA512:
6
- metadata.gz: 2d3d568386dfb35f13a820c8b6d4ec7a0381958dc1cc387932f844c50deeb40f6afd3c9041edfb4222d5506ef358dc837f3709a22fac6ba28d5169b51efe1be9
7
- data.tar.gz: 43ec54add0ff08ec20ba708db5c3de12555c2d260e17314696ee6ac2c7bc3957912e800fdfbea66412883375dbcc9d1ea8f932c4b36dff34ddd59c22081938a5
6
+ metadata.gz: fad6e4138146acb5e5afc4ad9b9522aad4179fecdd97dd97f822fcacac49eb8dcceaed6fde41ff09f397d8aa074f7366f28175fb3e26d62acc7fb7126065ff2a
7
+ data.tar.gz: ea01b9e4e5ca7d82e9e26f51907a62609a6c1edfcf994735031cd576810bdec80c23785b881609c3eaffecdb23d91d86b4ac7269305015093a5d3e9cc8364601
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- kamifusen (1.3)
4
+ kamifusen (1.4)
5
5
  image_processing
6
6
  rails
7
7
 
@@ -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=\"#{ options[:alt] }\"" if alt
11
- parameters += " width=\"#{ options[:width] }\"" if width
12
- parameters += " height=\"#{ options[:height]}\"" if height
13
- parameters += " class=\"#{ options[:class] }\"" if klass
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]
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Kamifusen
4
- VERSION = "1.3"
4
+ VERSION = "1.4"
5
5
  end
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.3'
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-02 00:00:00.000000000 Z
12
+ date: 2021-07-07 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rails