如何让redmine中问题或论坛中图片附件自动预览

最近公司在推行redmine用做项目管理的工具来使用,但是在新增加任务或者论坛消息时候有个问题,新增加图片的话,在查看问题或消息的时候,无法预览,必须点击一次,在新窗口打开,非常费事,所以考虑是不是有什么方法可以解决这个问题,于是就看到了“redmine_lightbox”有相关的代码,于是将之复制到redmine里面,一实验,果然可以,贡献:


修改 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>


 

原文链接: http://wmcxy.iteye.com/blog/1265608

你可能感兴趣的:(项目管理,redmine,图片预览)