Sha256: c9304e50819a69371d83b6a3e5f3997680300e4f7272ebe0cd395715303f391a

Contents?: true

Size: 926 Bytes

Versions: 1

Compression:

Stored size: 926 Bytes

Contents

module FacebookCoverResize
  module ViewHelpers
    def event_cover_tag(args)
      tag_generator(args.update(ratio: 1.91))
    end

    def account_cover_tag(args)
      tag_generator(args.update(ratio: 2.66))
    end

    def tag_generator(args)
      dims = FacebookCoverResize.compute(original: args[:original], offsets: args[:offsets], width: args[:width], ratio: args[:ratio])
      width = args[:width].to_i
      height = (width / args[:ratio]).ceil
      source = args[:source]

      content_tag(:div,
        image_tag(source,
          style: "position: absolute !important;top: #{dims[0]}px !important;left: #{dims[1]}px !important;width: #{dims[2]}px !important;height:#{dims[3]}px !important; margin: 0 !important"
        ),
        style: "width: #{width}px !important; height: #{height}px !important; overflow: hidden !important;position: relative !important; padding:0 !important"
      )
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
facebook_cover_resize-0.2.0 lib/facebook_cover_resize/view_helpers.rb