<%

  attachment = attribute.split('_file_name').first

  unless @item.send(attribute).blank?
    item = @item.send(attachment)
    preview = if @item.send("#{attachment}_content_type") =~ /^image\/.+/ && item.styles.member?(:typus_thumbnail)
                image_tag item.url(:typus_thumbnail)
              else
                link_to @item.send(attribute), item.url
              end
  end

%>

<li><label for="item_<%= attribute %>"><%= _(attachment.humanize) %></label>
<%= file_field :item, attachment, :disabled => attribute_disabled?(attribute) %>
<%= preview %>
</li>
<%- content_for :stylesheets do -%>
  <%= stylesheet_link_tag 'admin/jquery.fancybox', :media => 'screen' %>
<%- end -%>

<%- content_for :javascripts do -%>

  <%= javascript_include_tag 'admin/jquery-1.3.2.min' %>
  <%= javascript_include_tag 'admin/jquery.fancybox-1.2.1.min' %>

  <script type="text/javascript" charset="utf-8">
    $(document).ready(function() {
      $("#<%= @item.to_dom %>").fancybox();
    });
  </script>

<%- end -%>

<%

  attachment = attribute.split('_file_name').first

  unless @item.send(attribute).blank?
    item = @item.send(attachment)
    preview = if @item.send("#{attachment}_content_type") =~ /^image\/.+/ && item.styles.member?(:typus_thumbnail)
                <<-HTML
<a id="#{@item.to_dom}" href="#{@item.send(attachment).url(:typus_preview)}" title="#{@item.send(attribute)}">
#{image_tag item.url(:typus_thumbnail)}
</a>
                HTML
              else
                <<-HTML
#{link_to @item.send(attribute), item.url}
                HTML
              end
  end

%>

<li><label for="item_<%= attribute %>"><%= _(attachment.humanize) %></label>
<%= file_field :item, attachment, :disabled => attribute_disabled?(attribute) %>
<%= preview %>
</li>
Use fancybox to display images.
Use fancybox to display images.
