diff --git a/Gemfile.lock b/Gemfile.lock index ddd9d730..2f0b94ff 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,7 +1,7 @@ PATH remote: . specs: - binda (0.1.5) + binda (0.1.6) aasm (>= 4.11, < 4.13) ancestry (>= 2.1, < 3.1) bourbon (= 4.3.4) diff --git a/app/models/binda/image.rb b/app/models/binda/image.rb index 0c0164a7..2aa6545d 100644 --- a/app/models/binda/image.rb +++ b/app/models/binda/image.rb @@ -4,6 +4,9 @@ class Image < Asset mount_uploader :image, ImageUploader + # Register image details + # + # This method is used by a rake task def register_deatils if !self.image.present? puts "Ops, there is no image for Binda::Image id=#{self.id}" @@ -16,6 +19,9 @@ def register_deatils end end + # Register image details + # + # This method is used by register_deatils in a rake task def register_details_of(file) self.file_width = file.width self.file_height = file.height diff --git a/app/models/concerns/binda/fieldable_association_helpers.rb b/app/models/concerns/binda/fieldable_association_helpers.rb index 9f862f4e..4e0913bb 100644 --- a/app/models/concerns/binda/fieldable_association_helpers.rb +++ b/app/models/concerns/binda/fieldable_association_helpers.rb @@ -142,7 +142,7 @@ def get_image_info(field_slug, size, info) # Get image size # # @param field_slug [string] The slug of the field setting - # @return [string] with image type + # @return [float] with image type def get_image_size(field_slug) obj = self.images.find{ |t| t.field_setting_id == FieldSetting.get_id( field_slug ) } return bytes_to_megabytes(obj.file_size) @@ -165,7 +165,7 @@ def get_image_mime_type(field_slug) # Get image dimension # # @param field_slug [string] The slug of the field setting - # @return [hash] with width and height + # @return [hash] with width and height as floats def get_image_dimension(field_slug) obj = self.images.find{ |t| t.field_setting_id == FieldSetting.get_id( field_slug ) } return { width: obj.file_width, height: obj.file_height } diff --git a/config/initializers/simple_form__fileupload.rb b/config/initializers/simple_form__fileupload.rb index f0d0a710..22c7fe53 100644 --- a/config/initializers/simple_form__fileupload.rb +++ b/config/initializers/simple_form__fileupload.rb @@ -83,15 +83,14 @@ def detail(wrapper_options = nil) html << '

' html << "#{t 'binda.filesize'}: " html << '' - html << bytes_to_megabytes(obj.file_size).to_s if obj.image.present? && !obj.file_size.blank? - html << bytes_to_megabytes(obj.file_size).to_s if obj.video.present? && !obj.file_size.blank? + html << bytes_to_megabytes(obj.file_size).to_s unless obj.file_size.blank? html << 'MB

' html << '

' html << "#{t 'binda.filedimension'}: " html << '' - html << obj.file_width.round.to_s unless obj.image.present? && obj.file_width.blank? + html << obj.file_width.round.to_s unless obj.file_width.blank? html << ' x ' - html << obj.file_height.round.to_s unless obj.image.present? && obj.file_height.blank? + html << obj.file_height.round.to_s unless obj.file_height.blank? html << ' px

' html << '