diff --git a/app/controllers/projects/wikis_controller.rb b/app/controllers/projects/wikis_controller.rb
index 496064c9a6558da73b68b58ab3fb0c6cf3cc84e7..0e03956e7382bf24bb402e38a4cd0e3b6b43aeb0 100644
--- a/app/controllers/projects/wikis_controller.rb
+++ b/app/controllers/projects/wikis_controller.rb
@@ -12,12 +12,10 @@ class Projects::WikisController < Projects::ApplicationController
 
   def show
     @page = @project_wiki.find_page(params[:id], params[:version_id])
-    gollum_wiki = @project_wiki.wiki
-    file = gollum_wiki.file(params[:id], gollum_wiki.ref, true)
 
     if @page
       render 'show'
-    elsif file
+    elsif file = @project_wiki.find_file(params[:id], params[:version_id])
        if file.on_disk?
          send_file file.on_disk_path, disposition: 'inline'
        else
diff --git a/app/models/project_wiki.rb b/app/models/project_wiki.rb
index 08a527824751382707679baaa8bb83937f84d17d..a8ba5efcc7c19206ecb89c8bba24623cf1e6b4cc 100644
--- a/app/models/project_wiki.rb
+++ b/app/models/project_wiki.rb
@@ -72,6 +72,15 @@ class ProjectWiki
     end
   end
 
+  def find_file(name, version = nil, try_on_disk = true)
+    version = wiki.ref if version.nil? # Gollum::Wiki#file ?
+    if wiki_file = wiki.file(name, version, try_on_disk)
+      wiki_file
+    else
+      nil
+    end
+  end
+
   def create_page(title, content, format = :markdown, message = nil)
     commit = commit_details(:created, message, title)
 
diff --git a/spec/models/project_wiki_spec.rb b/spec/models/project_wiki_spec.rb
index 32a82470e4fe2f4d3ed39a6826d0807bb149830a..f06a5cd4ecc3474dba07f9598a8aa79df796ebcf 100644
--- a/spec/models/project_wiki_spec.rb
+++ b/spec/models/project_wiki_spec.rb
@@ -149,6 +149,40 @@ describe ProjectWiki do
     end
   end
 
+  describe '#find_file' do
+    before do
+      file = Gollum::File.new(subject.wiki)
+      Gollum::Wiki.any_instance.
+                   stub(:file).with('image.jpg', 'master', true).
+                   and_return(file)
+      Gollum::File.any_instance.
+                   stub(:mime_type).
+                   and_return('image/jpeg')
+      Gollum::Wiki.any_instance.
+                   stub(:file).with('non-existant', 'master', true).
+                   and_return(nil)
+    end
+
+    after do
+      Gollum::Wiki.any_instance.unstub(:file)
+      Gollum::File.any_instance.unstub(:mime_type)
+    end
+
+    it 'returns the latest version of the file if it exists' do
+      file = subject.find_file('image.jpg')
+      file.mime_type.should == 'image/jpeg'
+    end
+
+    it 'returns nil if the page does not exist' do
+      subject.find_file('non-existant').should == nil
+    end
+
+    it 'returns a Gollum::File instance' do
+      file = subject.find_file('image.jpg')
+      file.should be_a Gollum::File
+    end
+  end
+
   describe "#create_page" do
     after do
       destroy_page(subject.pages.first.page)