Sha256: 9b01b79631d493384ff900ca49095c67125b65df1053cf25d0105a9282d8cbed
Contents?: true
Size: 1.38 KB
Versions: 1
Compression:
Stored size: 1.38 KB
Contents
<% # name: headmin/thumbnail # # ==== Required parameters # * +src+ - Sourch path for the file # # ==== Optional parameters # * +width+ - Width of the thumbnail # * +height+ - Height of the thumbnail # # ==== References # https://getbootstrap.com/docs/5.1/content/images/#image-thumbnails # # ==== Examples # Basic version # <%= render 'headmin/thumbnail', src: file %#> # # Custom width and height # <%= render 'headmin/thumbnail', src: file, width: 300, height: 100 %#> width = local_assigns[:width] || 150 height = local_assigns[:height] || 150 class_names = ['img-thumbnail h-thumbnail', local_assigns[:class]].join(' ') mime_type = nil if src stripped_path = URI.parse(src).path extension = File.extname(stripped_path) mime_type = Rack::Mime.mime_type(extension) end %> <div class="<%= class_names %>" style="width: <%= width %>px; height: <%= height %>px;"> <% if mime_type&.match?(/^image/) %> <div class="h-thumbnail-bg" style="background-image: url('<%= src %>');"></div> <% else %> <div class="h-thumbnail-bg"> <%= src ? File.extname(src) : 'nil' %> <%= mime_type %> <% if mime_type %> <%= bootstrap_icon_for_mime_type(mime_type, class: 'h-thumbnail-icon') %> <% else %> <%= bootstrap_icon('question', class: 'h-thumbnail-icon') %> <% end %> </div> <% end %> </div>
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
headmin-0.3.1 | app/views/headmin/_thumbnail.html.erb |