Skip to content
This repository has been archived by the owner on Jul 19, 2021. It is now read-only.

Image details

Compare
Choose a tag to compare
@a-barbieri a-barbieri released this 06 Feb 14:17
· 197 commits to master since this release

How to upgrade from 0.1.4

In order to add image details related to width, height and content type create a new migration by running these from terminal:

rails generate migration addFileSizeAndContentType

On the new migration db/migrate/XXXXXXX_add_file_size_and_content_type.rb add the following code

  def change
  	add_column :binda_assets, :file_width, :float
  	add_column :binda_assets, :file_height, :float
  	add_column :binda_assets, :file_size, :float
  	add_column :binda_assets, :content_type, :string
  end

At this point you can update the db by running the following line from terminal:

rails db:migrate

Now it's possible to update any previous Binda::Image by running the following task.

rails binda:update_image_details

Deprecated methods

old method new method
has_repeater has_repeaters
get_repeater get_repeaters
get_selection_choice get_selection_choices

New features

Binda::Image now stores size, dimension and mime type of the image.
You can retrieve those details with the following methods.

image_setting = Binda::FieldSetting.find_by(slug: 'my-image')
component = Binda::Component.first
get_image_size('my-image')
# => 123.0
get_image_dimension('my-image')
# => { width: 123.0, height: 123.0 }
get_image_mime_type('my-image')
# => 'image/jpeg'

Fixes