AlchemyCMS/alchemy_cms

View on GitHub
app/views/alchemy/admin/pictures/_picture.html.erb

Summary

Maintainability
Test Coverage
<div class="picture_thumbnail <%= @size %>" id="picture_<%= picture.id %>" name="<%= picture.name %>">
  <span class="picture_tool select">
    <%= check_box_tag "picture_ids[]", picture.id %>
  </span>
  <% if picture.deletable? && can?(:destroy, picture) %>
  <span class="picture_tool delete">
    <sl-tooltip content="<%= Alchemy.t('Delete image') %>">
      <%= link_to_confirm_dialog(
        render_icon("delete-bin-2"),
        Alchemy.t(:confirm_to_delete_image_from_server),
        alchemy.admin_picture_path(
          id: picture,
          q: search_filter_params[:q],
          page: params[:page],
          tagged_with: search_filter_params[:tagged_with],
          size: @size,
          filter: search_filter_params[:filter]
        )
      ) -%>
    </sl-tooltip>
  </span>
  <% end %>
  <% picture_url = picture.thumbnail_url(size: preview_size(@size)) %>
  <% image = image_tag(picture_url || "alchemy/missing-image.svg", alt: picture.name) %>
  <% if can?(:edit, picture) && picture_url %>
    <%= link_to(
      image,
      alchemy.admin_picture_path(
        id: picture,
        q: search_filter_params[:q],
        page: params[:page],
        tagged_with: search_filter_params[:tagged_with],
        size: @size,
        filter: search_filter_params[:filter]
      ),
      class: 'thumbnail_background'
    ) %>
  <% else %>
    <%= image %>
  <% end %>
  <span class="picture_name" title="<%= picture.name %>">
    <%= picture.name %>
  </span>
  <div class="picture_tags">
  <% picture.tag_list.each do |tag| %>
    <span class="tag"><%= tag %></span>
  <% end %>
  </div>
</div>