simple_form_bs5_file_input 0.1.6 → 0.2.1

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: 8f3768368abae3e5c352f6cebc4fcf5d164c70382a91ef3c3aa4e79b69d1d8fe
4
+ data.tar.gz: ccab858f139fa40fbd3299b284af68705088b31045e228e3e57979c8e7c2e9c8
5
5
  SHA512:
6
- metadata.gz: 65d0c4998529d77d4d5a9c8b859fd754f3e6f4a7c8675b140fc47ae811bb24f3e4974df1ddcdce46f790f4adef6b706bc5bd963ff6b146550274dfb9ebd4b61f
7
- data.tar.gz: b014540be1c63981422aa16c85c37cd04255dcce2e811bfd9a2c9cff15dd88e1da5a3d2f28223d9ba5b3a3e50b6e6ff436e3c6075b0976f6cd6a870d09c217f8
6
+ metadata.gz: 95c21f322ffe355b636ebf2d2978a4fe1175401847b03830fdfdcdbf2fe351585247a601df7eb8e38885b0ac772893318793c73ce8dd80ce15fd3b78bd72c91d
7
+ data.tar.gz: 23c71278b3ee98531b7799a4f8c51e477022669702ba7aea6d0d187ebd251dd59b405252cd552822c6d01fa8bcb225b53b0da1f99c46e5d89cf749ed1ea9d027
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.1)
5
5
  rails
6
6
  simple_form
7
7
 
@@ -34,18 +34,30 @@ 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
+ if ActiveStorage.variant_processor == :mini_magick
44
+ # From Rails 6, ImageProcessing with MiniMagick uses an 'auto-orient' by default to interpret the EXIF Orientation metadata.
45
+ transformations[:'auto-orient'] = true
46
+ # Handle rotation
47
+ transformations[:rotate] = rotation if rotation.present?
48
+ # Handle cropping
49
+ transformations[:crop] = "#{width}x#{height}+#{left}+#{top}"
50
+ # Finalize by repaging
51
+ transformations.merge!({
52
+ repage: true,
53
+ :'+' => true
54
+ })
55
+ elsif ActiveStorage.variant_processor == :vips
56
+ # Handle rotation
57
+ transformations[:rotate] = rotation if rotation.present?
58
+ # Handle cropping
59
+ transformations[:crop] = [left, top, width, height]
60
+ end
49
61
 
50
62
  variant = Rails::VERSION::MAJOR >= 6 ? send(name).variant(**transformations)
51
63
  : 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.1".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.1
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: []