app/views/headmin/_thumbnail.html.erb in headmin-0.5.3 vs app/views/headmin/_thumbnail.html.erb in headmin-0.5.4
- old
+ new
@@ -1,11 +1,35 @@
-<% thumbnail = Headmin::ThumbnailView.new(local_assigns) %>
+<%
+ # headmin/thumbnail
+ #
+ # ==== Required parameters
+ # * +file+ - Name of the attribute of the form model
+ #
+ # ==== Optional parameters
+ # * +width+ - Width of the thumbnail. Set to nil to fill according to the original aspect ratio
+ # * +height+ - Height of the thumbnail. Set to nil to fill according to the original aspect ratio
+ # * +icon+ - Force icon to be shown instead of a thumbnail
+ #
+ # ==== References
+ # https://headmin.dev/docs/thumbnail
+ #
+ # ==== Examples
+ # Basic version
+ # <%= render "headmin/thumbnail", file: file %#>
+ #
+ # Custom size (200px x 100px)
+ # <%= render "headmin/thumbnail", file: file, width: 200, height: 100 %#>
+ #
+ # Custom (bootstrap) icon
+ # <%= render "headmin/thumbnail", file: file, icon: "file-earmark-excel" %#>
+ thumbnail = Headmin::ThumbnailView.new(local_assigns)
+%>
-<div class="<%= thumbnail.class_names %>" style="width: <%= thumbnail.width %>px; height: <%= thumbnail.height %>px;">
- <% if thumbnail.image? %>
- <div class="h-thumbnail-bg" style="background-image: url('<%= thumbnail.src %>');"></div>
- <% else %>
- <div class="h-thumbnail-bg">
+<div class="<%= thumbnail.class_names %>">
+ <div class="h-thumbnail-bg" style="min-width: <%= thumbnail.width || 100 %>px; min-height: <%= thumbnail.height || 100 %>px;">
+ <% if thumbnail.variable? && !thumbnail.icon? %>
+ <%= image_tag(thumbnail.file.variant(thumbnail.variant_options)) %>
+ <% else %>
<%= bootstrap_icon(thumbnail.icon_name, class: "h-thumbnail-icon") %>
- </div>
- <% end %>
+ <% end %>
+ </div>
</div>