Commit e4fa08c6 authored by Klaus Stein's avatar Klaus Stein
Browse files

Temporarily fix uploads of non-resizable image stuff

Like someone uploading a pdf instead of an image
parent 4618d6d0
...@@ -42,7 +42,7 @@ class ImageMap < ApplicationRecord ...@@ -42,7 +42,7 @@ class ImageMap < ApplicationRecord
# we predefine some variants # we predefine some variants
def image_preview def image_preview
if image? if image? && self.image.variable?
self.image.variant(resize_to_limit: [10000, 200], self.image.variant(resize_to_limit: [10000, 200],
auto_orient: true, auto_orient: true,
format: :jpg).processed format: :jpg).processed
...@@ -50,7 +50,7 @@ class ImageMap < ApplicationRecord ...@@ -50,7 +50,7 @@ class ImageMap < ApplicationRecord
end end
def image_thumbnail def image_thumbnail
if image? if image? && self.image.variable?
self.image.variant(resize_to_limit: [50, 50], self.image.variant(resize_to_limit: [50, 50],
auto_orient: true, auto_orient: true,
format: :jpg).processed format: :jpg).processed
...@@ -58,7 +58,7 @@ class ImageMap < ApplicationRecord ...@@ -58,7 +58,7 @@ class ImageMap < ApplicationRecord
end end
def image_hd def image_hd
if image? if image? && self.image.variable?
self.image.variant(resize_to_limit: [1920, 1200], self.image.variant(resize_to_limit: [1920, 1200],
auto_orient: true, auto_orient: true,
format: :jpg).processed format: :jpg).processed
......
...@@ -21,7 +21,7 @@ ...@@ -21,7 +21,7 @@
<tr> <tr>
<th>Image:</th> <th>Image:</th>
<td><% img = @image_map.image_preview %> <td><% img = @image_map.image_preview %>
<%= image_tag img %><br /> <%= image_tag img || '#' %><br />
<%#= url_for(@image_map.image) %></td> <%#= url_for(@image_map.image) %></td>
</tr> </tr>
<tr> <tr>
......
...@@ -3,7 +3,11 @@ ...@@ -3,7 +3,11 @@
<td class="img"><%= <td class="img"><%=
image_map = form.object image_map = form.object
if image_map.image? if image_map.image?
image_tag image_map.image_preview if p = image_map.image_preview
image_tag p
else
image_map.name || '–?–'
end
else else
form.file_field :image, direct_upload: true form.file_field :image, direct_upload: true
end end
......
...@@ -34,7 +34,7 @@ ...@@ -34,7 +34,7 @@
<div class="previews"> <div class="previews">
<% @map.image_maps.each do |im| %> <% @map.image_maps.each do |im| %>
<figure> <figure>
<%= link_to image_tag(im.image_preview, <%= link_to image_tag(im.image_preview || '#',
class: 'preview', alt: im.name, title: im.id), class: 'preview', alt: im.name, title: im.id),
url_for(im.image_hd), target: '_blank', title: im.name %> url_for(im.image_hd), target: '_blank', title: im.name %>
<figcaption> <figcaption>
......
...@@ -24,7 +24,7 @@ ...@@ -24,7 +24,7 @@
<%= link_to(map, class: 'map') do %> <%= link_to(map, class: 'map') do %>
<span class="imgicon"> <span class="imgicon">
<% if im = map.image_maps.first %> <% if im = map.image_maps.first %>
<%= image_tag im.image_thumbnail %> <%= image_tag im.image_thumbnail || '#' %>
<% end %> <% end %>
</span> </span>
<span class="maptitle"><%= (map.label || '– no title –') %></span> <span class="maptitle"><%= (map.label || '– no title –') %></span>
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment