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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 42e4345e5d359096961d48f2c5477fbcdf6fafec4b84f2ca32dc6e410a2502fa
4
- data.tar.gz: d2b920f457438f5652c14cffd7d14032637549e10a753f1244cb95da3706e475
3
+ metadata.gz: cc7dc54c21db20fd2cfd6a7aec2c5b50aa7ee13f725648293246a5972f973240
4
+ data.tar.gz: 0f6d32fbe3006abc1d018916b66a71dbd20bd9e9edacf11ea5c4e841e446e5ca
5
5
  SHA512:
6
- metadata.gz: e3c68441c27a9e4533d74975f2a57ebb0bffa59bfe66cc32f9ce2846c897d090b24d3ebf338fbc5de180d2368f4b56a84e81258b9866552f691e5f8740b934d2
7
- data.tar.gz: 3334ffd8b926960203b4586f779130d00ad6d2c0010d02e7f2b419bfd2d2389d11be128f8901970fbff5f8f2705e9dbbb5ace3dda2bd7ec01f4f5dfc1719d20c
6
+ metadata.gz: ae20b1464beb842cc4a17275b2d154a3bf572405b8c7a97be7acd57e91245571460fbac7fdefff62e380cd0a6a21e6fb863df950d6f4d2552cde7a3faa80acd8
7
+ data.tar.gz: d120ad3e78b7094c352874b7fbafd611a6017eeef5cb2e621879e0863f310ef5a512b7ac58126c51d344647d40cc069837f7aa94a34c05af8733a1c40c5e1fac
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- kamifusen (1.6)
4
+ kamifusen (1.7)
5
5
  image_processing
6
6
  rails
7
7
 
@@ -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 = [320, 576, 640, 768, 992, 1152, 1200, 1400, 1536, 1984, 2400]
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
- "#{ url_for source.variant(resize: "#{size}>", format: :webp, quality: quality) } #{ size }w"
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
- "#{ url_for source.variant(resize: "#{size}>", quality: quality) } #{ size }w"
84
+ variant = source.variant(resize: "#{size}>", quality: quality)
85
+ "#{ kamifusen_process(variant, active_storage_direct_url) } #{ size }w"
67
86
  }.join(', ')
68
- default = url_for source.variant(resize: "#{default_width}>", quality: quality)
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 %>
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Kamifusen
4
- VERSION = "1.6"
4
+ VERSION = "1.7"
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.6'
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-16 00:00:00.000000000 Z
12
+ date: 2021-09-17 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rails