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
# we predefine some variants
def image_preview
if image?
if image? && self.image.variable?
self.image.variant(resize_to_limit: [10000, 200],
auto_orient: true,
format: :jpg).processed
......@@ -50,7 +50,7 @@ class ImageMap < ApplicationRecord
end
def image_thumbnail
if image?
if image? && self.image.variable?
self.image.variant(resize_to_limit: [50, 50],
auto_orient: true,
format: :jpg).processed
......@@ -58,7 +58,7 @@ class ImageMap < ApplicationRecord
end
def image_hd
if image?
if image? && self.image.variable?
self.image.variant(resize_to_limit: [1920, 1200],
auto_orient: true,
format: :jpg).processed
......
......@@ -21,7 +21,7 @@
<tr>
<th>Image:</th>
<td><% img = @image_map.image_preview %>
<%= image_tag img %><br />
<%= image_tag img || '#' %><br />
<%#= url_for(@image_map.image) %></td>
</tr>
<tr>
......
......@@ -3,7 +3,11 @@
<td class="img"><%=
image_map = form.object
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
form.file_field :image, direct_upload: true
end
......
......@@ -34,7 +34,7 @@
<div class="previews">
<% @map.image_maps.each do |im| %>
<figure>
<%= link_to image_tag(im.image_preview,
<%= link_to image_tag(im.image_preview || '#',
class: 'preview', alt: im.name, title: im.id),
url_for(im.image_hd), target: '_blank', title: im.name %>
<figcaption>
......
......@@ -24,7 +24,7 @@
<%= link_to(map, class: 'map') do %>
<span class="imgicon">
<% if im = map.image_maps.first %>
<%= image_tag im.image_thumbnail %>
<%= image_tag im.image_thumbnail || '#' %>
<% end %>
</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