修改 app\views\attachments\_links.rhtml这个文件,如果显示全图的话,增加以下代码即可:
<SPAN style="FONT-SIZE: medium"><% images = attachments.select { |a| a.image? } %>
<% unless images.empty? %>
<div class='images'>
<% images.each do |attachment| %>
<%= link_to image_tag(url_for({:controller => 'attachments', :action => 'show', :id => attachment, :filename => attachment.filename })),
{:controller => 'attachments', :action => 'show', :id => attachment, :filename => attachment.filename }, :class => 'lightbox', :rel => 'attachments', :title => "#{attachment.filename}#{ ('-' + attachment.description) unless attachment.description.blank? }" %>
<% end -%>
</div>
<% end -%></SPAN>
如果希望先显示的 预览图片,则需要增加:多了一个参数“width => '180'”180就是你设置的宽度:
<SPAN style="FONT-SIZE: medium"><% images = attachments.select { |a| a.image? } %>
<% unless images.empty? %>
<div class='images'>
<% images.each do |attachment| %>
<%= link_to image_tag(url_for({:controller => 'attachments', :action => 'show', :id => attachment, :filename => attachment.filename }), :width => '180'),
{:controller => 'attachments', :action => 'show', :id => attachment, :filename => attachment.filename }, :class => 'lightbox', :rel => 'attachments', :title => "#{attachment.filename}#{ ('-' + attachment.description) unless attachment.description.blank? }" %>
<% end -%>
</div>
<% end -%></SPAN>
覆盖app\views\attachments\_links.rhtml即可