Index: app/models/attachment.rb =================================================================== --- app/models/attachment.rb (revision 1163) +++ app/models/attachment.rb (working copy) @@ -31,6 +31,7 @@ cattr_accessor :storage_path @@storage_path = "#{RAILS_ROOT}/files" + @@image_path = "#{RAILS_ROOT}/public/images/files" def validate errors.add_to_base :too_long if self.filesize > Setting.attachment_max_size.to_i.kilobytes @@ -54,6 +55,7 @@ # Copy temp file to its final location def before_save + FileUtils.makedirs(@@image_path) unless File.directory?(@@image_path) if @temp_file && (@temp_file.size > 0) logger.debug("saving '#{self.diskfile}'") File.open(diskfile, "wb") do |f| @@ -76,7 +78,11 @@ # Returns file's location on disk def diskfile - "#{@@storage_path}/#{self.disk_filename}" + if self.image? + "#{@@image_path}/#{self.disk_filename}" + else + "#{@@storage_path}/#{self.disk_filename}" + end end def increment_download Index: app/views/attachments/_links.rhtml =================================================================== --- app/views/attachments/_links.rhtml (revision 1163) +++ app/views/attachments/_links.rhtml (working copy) @@ -1,7 +1,12 @@
<% for attachment in attachments %> -

<%= link_to attachment.filename, {:controller => 'attachments', :action => 'download', :id => attachment }, :class => 'icon icon-attachment' %> - (<%= number_to_human_size attachment.filesize %>) +

+ <% if attachment.image? and attachment.project.show_image? %> + <%=image_tag('files/'+attachment.disk_filename)%> + <% else %> + <%= link_to attachment.filename, {:controller => 'attachments', :action => 'download', :id => attachment }, :class => 'icon icon-attachment' %> + <% end %> + (<%= number_to_human_size attachment.filesize %>) <% unless options[:no_author] %> <%= attachment.author.name %>, <%= format_date(attachment.created_on) %> <% end %> Index: app/views/projects/_form.rhtml =================================================================== --- app/views/projects/_form.rhtml (revision 1163) +++ app/views/projects/_form.rhtml (working copy) @@ -15,6 +15,7 @@ <% end %>

<%= f.text_field :homepage, :size => 40 %>

<%= f.check_box :is_public %>

+

<%= f.check_box :show_image %>

<%= wikitoolbar_for 'project_description' %> <% for @custom_value in @custom_values %> Index: lang/en.yml =================================================================== --- lang/en.yml (revision 1163) +++ lang/en.yml (working copy) @@ -131,6 +131,7 @@ field_role: Role field_homepage: Homepage field_is_public: Public +field_show_image: Show attached images field_parent: Subproject of field_is_in_chlog: Issues displayed in changelog field_is_in_roadmap: Issues displayed in roadmap Index: db/migrate/089_add_project_is_image_show.rb =================================================================== --- db/migrate/089_add_project_is_image_show.rb (revision 0) +++ db/migrate/089_add_project_is_image_show.rb (revision 0) @@ -0,0 +1,9 @@ +class AddProjectIsImageShow < ActiveRecord::Migration + def self.up + add_column :projects, :show_image, :boolean, :default => false, :null => false + end + + def self.down + remove_column :projects, :show_image + end +end