Module: Fields::CloudinaryImageHelper

Defined in:
app/helpers/fields/cloudinary_image_helper.rb

Instance Method Summary collapse

Instance Method Details

#cloudinary_image_tag(cloudinary_id, image_tag_options = {}, cloudinary_image_options = {}) ⇒ Object



2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
# File 'app/helpers/fields/cloudinary_image_helper.rb', line 2

def cloudinary_image_tag(cloudinary_id, image_tag_options = {}, cloudinary_image_options = {})
  return nil unless cloudinary_id.present?

  if image_tag_options[:width]
    cloudinary_image_options[:width] ||= image_tag_options[:width] * 2
  end

  if image_tag_options[:height]
    cloudinary_image_options[:height] ||= image_tag_options[:height] * 2
  end

  cloudinary_image_options[:crop] ||= :fill

  image_tag cl_image_path(cloudinary_id, cloudinary_image_options), image_tag_options
end