如何讓redmine中問題或論壇中圖片附件自動預覽

來源:互聯網
上載者:User

最近公司在推行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

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.