Feature #22058 » 0003-Add-inline-image-preview-display-for-attachments-and.patch
app/controllers/attachments_controller.rb | ||
---|---|---|
40 | 40 |
elsif @attachment.is_text? && @attachment.filesize <= Setting.file_max_size_displayed.to_i.kilobyte |
41 | 41 |
@content = File.new(@attachment.diskfile, "rb").read |
42 | 42 |
render :action => 'file' |
43 |
elsif @attachment.is_image? |
|
44 |
render :action => 'image' |
|
43 | 45 |
else |
44 | 46 |
download |
45 | 47 |
end |
app/controllers/repositories_controller.rb | ||
---|---|---|
170 | 170 | |
171 | 171 |
@content = @repository.cat(@path, @rev) |
172 | 172 |
(show_error_not_found; return) unless @content |
173 |
if is_raw || |
|
173 |
if !is_raw && Redmine::MimeType.is_type?('image', @path) |
|
174 |
# simply render |
|
175 |
elsif is_raw || |
|
174 | 176 |
(@content.size && @content.size > Setting.file_max_size_displayed.to_i.kilobyte) || |
175 | 177 |
! is_entry_text_data?(@content, @path) |
176 | 178 |
# Force the download |
app/models/attachment.rb | ||
---|---|---|
237 | 237 |
Redmine::MimeType.is_type?('text', filename) |
238 | 238 |
end |
239 | 239 | |
240 |
def is_image? |
|
241 |
Redmine::MimeType.is_type?('image', filename) |
|
242 |
end |
|
243 | ||
240 | 244 |
def is_diff? |
241 | 245 |
self.filename =~ /\.(patch|diff)$/i |
242 | 246 |
end |
app/views/attachments/_links.html.erb | ||
---|---|---|
8 | 8 |
</div> |
9 | 9 |
<% for attachment in attachments %> |
10 | 10 |
<p><%= link_to_attachment attachment, :class => 'icon icon-attachment', :download => true -%> |
11 |
<% if attachment.is_text? %> |
|
11 |
<% if attachment.is_text? || attachment.is_image? %>
|
|
12 | 12 |
<%= link_to l(:button_view), |
13 | 13 |
{ :controller => 'attachments', :action => 'show', |
14 | 14 |
:id => attachment, :filename => attachment.filename }, |
app/views/attachments/image.html.erb | ||
---|---|---|
1 |
<%= render :layout => 'layouts/file' do %> |
|
2 |
<%= render :partial => 'common/image', :locals => {:path => download_named_attachment_url(@attachment, @attachment.filename), :alt => @attachment.filename} %> |
|
3 |
<% end %> |
app/views/common/_image.html.erb | ||
---|---|---|
1 |
<%= image_tag path, :alt => alt, :class => 'filecontent image' %> |
app/views/repositories/entry.html.erb | ||
---|---|---|
8 | 8 | |
9 | 9 |
<%= render :partial => 'link_to_functions' %> |
10 | 10 | |
11 |
<% if Redmine::MimeType.is_type?('image', @path) %> |
|
12 |
<%= render :partial => 'common/image', :locals => {:path => url_for(params.merge(:action => 'raw')), :alt => @path} %> |
|
13 |
<% else %> |
|
11 | 14 |
<%= render :partial => 'common/file', :locals => {:filename => @path, :content => @content} %> |
15 |
<% end %> |
|
12 | 16 | |
13 | 17 |
<% content_for :header_tags do %> |
14 | 18 |
<%= stylesheet_link_tag "scm" %> |
public/stylesheets/scm.css | ||
---|---|---|
67 | 67 |
table.filecontent tr:target th.line-num { background-color:#E0E0E0; color: #777; } |
68 | 68 |
table.filecontent tr:target td.line-code { background-color:#DDEEFF; } |
69 | 69 | |
70 |
img.filecontent.image { max-width: 100%; } |
|
71 | ||
70 | 72 |
/* 12 different colors for the annonate view */ |
71 | 73 |
table.annotate tr.bloc-0 {background: #FFFFBF;} |
72 | 74 |
table.annotate tr.bloc-1 {background: #EABFFF;} |
- « Previous
- 1
- …
- 4
- 5
- 6
- Next »