Show images in files inline.
authorPeter Amstutz <peter.amstutz@curoverse.com>
Mon, 3 Mar 2014 13:43:12 +0000 (08:43 -0500)
committerPeter Amstutz <peter.amstutz@curoverse.com>
Mon, 3 Mar 2014 13:43:12 +0000 (08:43 -0500)
apps/workbench/app/views/collections/_show_files.html.erb

index 385af8a27205c98be3cb43974cb0bbde5c9740ce..9a503291c3233191fad950a6a7dc1096304e36c3 100644 (file)
       </td>
 
       <td>
-        <%= link_to file[1], {controller: 'collections', action: 'show_file', uuid: @object.uuid, file: file_path, size: file[2], disposition: 'inline'}, {title: 'View in browser'} %>
+        <%= link_to((if /\.(jpg|jpeg|gif|png)$/.match(file[1]) then
+                       image_tag "#{url_for @object}/#{file_path}"
+                     else
+                       file[1]
+                     end), 
+                    {controller: 'collections', action: 'show_file', uuid: @object.uuid, file: file_path, size: file[2], disposition: 'inline'}, 
+                    {title: 'View in browser'}) %>
       </td>
 
       <td style="text-align:right">