kamifusen 1.6 → 1.7
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/Gemfile.lock +1 -1
- data/app/views/kamifusen/_view.html.erb +24 -4
- 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: cc7dc54c21db20fd2cfd6a7aec2c5b50aa7ee13f725648293246a5972f973240
|
4
|
+
data.tar.gz: 0f6d32fbe3006abc1d018916b66a71dbd20bd9e9edacf11ea5c4e841e446e5ca
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ae20b1464beb842cc4a17275b2d154a3bf572405b8c7a97be7acd57e91245571460fbac7fdefff62e380cd0a6a21e6fb863df950d6f4d2552cde7a3faa80acd8
|
7
|
+
data.tar.gz: d120ad3e78b7094c352874b7fbafd611a6017eeef5cb2e621879e0863f310ef5a512b7ac58126c51d344647d40cc069837f7aa94a34c05af8733a1c40c5e1fac
|
data/Gemfile.lock
CHANGED
@@ -4,6 +4,8 @@ options ||= {}
|
|
4
4
|
alt = options[:alt]
|
5
5
|
async = options.has_key?(:async) ? options[:async]
|
6
6
|
: true
|
7
|
+
active_storage_direct_url = options.has_key?(:active_storage_direct_url) ? options[:active_storage_direct_url]
|
8
|
+
: false
|
7
9
|
klass = options[:class]
|
8
10
|
picture_class = options[:picture_class]
|
9
11
|
width = options[:width]
|
@@ -41,12 +43,27 @@ parameters += " alt=\"#{ alt }\"" if alt
|
|
41
43
|
parameters += " width=\"#{ width }\"" if width
|
42
44
|
parameters += " height=\"#{ height }\"" if height
|
43
45
|
parameters += " class=\"#{ klass }\"" if klass
|
46
|
+
|
47
|
+
def kamifusen_process(variant, active_storage_direct_url)
|
48
|
+
if active_storage_direct_url
|
49
|
+
begin
|
50
|
+
# Pour générer la processed url, il faut savoir où sont stockées les images
|
51
|
+
# https://discuss.rubyonrails.org/t/define-host-so-absolute-urls-work-in-development-and-test/75085
|
52
|
+
# https://stackoverflow.com/questions/60425407/uriinvalidurierror-bad-uriis-not-uri-nil-active-storage-service-url
|
53
|
+
# Not compatible with Disk storage, will return nil
|
54
|
+
url = variant.processed.url
|
55
|
+
rescue
|
56
|
+
end
|
57
|
+
end
|
58
|
+
url = url_for(variant) if url.nil?
|
59
|
+
url
|
60
|
+
end
|
44
61
|
%>
|
45
62
|
<% if source.variable? %>
|
46
63
|
<%#= "#{image_width} x #{image_height}, #{image_ratio} ratio => #{width} x #{height}<br>".html_safe %>
|
47
64
|
<%
|
48
65
|
# kamifusen settings
|
49
|
-
sizes = [
|
66
|
+
sizes = [360, 375, 414, 576, 640, 750, 768, 828, 992, 1152, 1200, 1366, 1400, 1536, 1920, 1984, 2400]
|
50
67
|
quality = 80
|
51
68
|
# Computing
|
52
69
|
if width
|
@@ -59,13 +76,16 @@ parameters += " class=\"#{ klass }\"" if klass
|
|
59
76
|
default_width = width_retina if width_retina && width_retina > default_width
|
60
77
|
if Kamifusen.with_webp
|
61
78
|
srcset_webp = sizes.map { |size|
|
62
|
-
|
79
|
+
variant = source.variant(resize: "#{size}>", format: :webp, quality: quality)
|
80
|
+
"#{ kamifusen_process(variant, active_storage_direct_url) } #{ size }w"
|
63
81
|
}.join(', ')
|
64
82
|
end
|
65
83
|
srcset_default = sizes.map { |size|
|
66
|
-
|
84
|
+
variant = source.variant(resize: "#{size}>", quality: quality)
|
85
|
+
"#{ kamifusen_process(variant, active_storage_direct_url) } #{ size }w"
|
67
86
|
}.join(', ')
|
68
|
-
|
87
|
+
variant = source.variant(resize: "#{default_width}>", quality: quality)
|
88
|
+
default = kamifusen_process(variant, active_storage_direct_url)
|
69
89
|
%>
|
70
90
|
<picture<%= " class=\"#{picture_class}\"".html_safe unless picture_class.blank? %>>
|
71
91
|
<% if Kamifusen.with_webp %>
|
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.7'
|
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-09-
|
12
|
+
date: 2021-09-17 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rails
|