Module: RailsPicture::RailsPictureHelper

Defined in:
lib/rails_picture/rails_picture_helper.rb

Overview

Add a helper method to Rails views

Constant Summary collapse

SOURCE_FORMATS =
%w[avif webp apng gif svg jxl bmp ico cur tif tiff].freeze
IMG_FORMATS =
%w[jpg jpeg png jfif pjpeg pjp].freeze

Instance Method Summary collapse

Instance Method Details

#picture_tag(filename, **options) ⇒ Object



10
11
12
13
14
15
16
17
18
# File 'lib/rails_picture/rails_picture_helper.rb', line 10

def picture_tag(filename, **options)
  html = []

  SOURCE_FORMATS.each { |f| html << build_source_tag(filename, f) }

  html << build_image_tag(filename, **options)

  tag.picture { safe_join html }
end