simple_form_bs5_file_input 0.1.6 → 0.2.0

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: ee672a494d530c3c1b9dc5cbddc3876da798275a247bfa326ad48668ce41a098
4
- data.tar.gz: e167386d3b3909ce71975e52f9e28f6f2db8f4f8cdd0c565dd4442032bac5a14
3
+ metadata.gz: 76ba13ef60f2f906d584bb3ab3de58a0aac7988dcf5217e85b117eeb0bf50ea4
4
+ data.tar.gz: aa98b74d4577a3e45952c0071fa8609653ed41d38650ebaca58f578af30364f9
5
5
  SHA512:
6
- metadata.gz: 65d0c4998529d77d4d5a9c8b859fd754f3e6f4a7c8675b140fc47ae811bb24f3e4974df1ddcdce46f790f4adef6b706bc5bd963ff6b146550274dfb9ebd4b61f
7
- data.tar.gz: b014540be1c63981422aa16c85c37cd04255dcce2e811bfd9a2c9cff15dd88e1da5a3d2f28223d9ba5b3a3e50b6e6ff436e3c6075b0976f6cd6a870d09c217f8
6
+ metadata.gz: 6c96e619a6a5dd7a43c6be6b45916fecee5adeaa119e86133877a0182656dc392558636c859966ade7076ea2542a4d220187c112d3b214176f8f4ea062e6cf90
7
+ data.tar.gz: f36e2e36f3af1dec08f19fd89a2fdf59409107ba47cb3e1e36430f2a7f729a34004468e46302bbc3c61b697e61112a23b0be8f84c8b9248128b184785bd459ee
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- simple_form_bs5_file_input (0.1.6)
4
+ simple_form_bs5_file_input (0.2.0)
5
5
  rails
6
6
  simple_form
7
7
 
@@ -34,18 +34,31 @@ class ActiveRecord::Base
34
34
  # reset the infos to prevent multiple resize if multiple save
35
35
  instance_variable_set :"@#{name}_infos", nil
36
36
 
37
- # From Rails 6, ImageProcessing uses an 'auto-orient' by default to interpret the EXIF Orientation metadata.
38
- # We declare it in the transformations hash for Rails 5
39
- transformations = { :'auto-orient' => true }
40
- # Handle rotation
41
- transformations[:rotate] = params['rotate'] if params['rotate'].present?
42
- # Handle cropping
43
- transformations[:crop] = "#{params['width'].round}x#{params['height'].round}+#{params['x'].round}+#{params['y'].round}"
44
- # Finalize by repaging
45
- transformations.merge!({
46
- repage: true,
47
- :'+' => true
48
- })
37
+ left = params['x'].round
38
+ top = params['y'].round
39
+ width = params['width'].round
40
+ height = params['height'].round
41
+ rotation = params['rotate']
42
+ transformations = {}
43
+ byebug
44
+ if ActiveStorage.variant_processor == :mini_magick
45
+ # From Rails 6, ImageProcessing with MiniMagick uses an 'auto-orient' by default to interpret the EXIF Orientation metadata.
46
+ transformations[:'auto-orient'] = true
47
+ # Handle rotation
48
+ transformations[:rotate] = rotation if rotation.present?
49
+ # Handle cropping
50
+ transformations[:crop] = "#{width}x#{height}+#{left}+#{top}"
51
+ # Finalize by repaging
52
+ transformations.merge!({
53
+ repage: true,
54
+ :'+' => true
55
+ })
56
+ elsif ActiveStorage.variant_processor == :vips
57
+ # Handle rotation
58
+ transformations[:rotate] = rotation if rotation.present?
59
+ # Handle cropping
60
+ transformations[:crop] = [left, top, width, height]
61
+ end
49
62
 
50
63
  variant = Rails::VERSION::MAJOR >= 6 ? send(name).variant(**transformations)
51
64
  : send(name).variant(combine_options: transformations)
@@ -135,7 +135,7 @@ class SingleDeletableFileInput < SimpleForm::Inputs::Base
135
135
  return unless should_display_file?
136
136
  # Fichier invariable, pas de chocolat non plus
137
137
  return unless file_attachment&.variable?
138
- variant = file_attachment.variant(resize: "#{preview_image_width}x")
138
+ variant = file_attachment.variant(resize_to_fit: [preview_image_width, nil])
139
139
  path = url_helpers.polymorphic_url variant, only_path: true
140
140
  image_tag path, class: 'img-fluid img-thumbnail', width: preview_image_width
141
141
  end
@@ -1,3 +1,3 @@
1
1
  module SimpleFormBs5FileInput
2
- VERSION = "0.1.6".freeze
2
+ VERSION = "0.2.0".freeze
3
3
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: simple_form_bs5_file_input
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.6
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Pierre-andré Boissinot
8
8
  bindir: bin
9
9
  cert_chain: []
10
- date: 2025-04-14 00:00:00.000000000 Z
10
+ date: 1980-01-02 00:00:00.000000000 Z
11
11
  dependencies:
12
12
  - !ruby/object:Gem::Dependency
13
13
  name: rails
@@ -107,7 +107,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
107
107
  - !ruby/object:Gem::Version
108
108
  version: '0'
109
109
  requirements: []
110
- rubygems_version: 3.6.2
110
+ rubygems_version: 3.6.9
111
111
  specification_version: 4
112
112
  summary: Simple Form BS5 File Input
113
113
  test_files: []