Project

General

Profile

« Previous | Next » 

Revision 4ef5bacc

Added by Marc Dequènes over 12 years ago

  • ID 4ef5bacc0c50575e64b8f6302e1a385043656441

[fix] ensure the default display size for a thumbnail (currently the full image) does not crash (closes #77)

View differences:

app/helpers/application_helper.rb
213 213
    table.content [_("Updated at:"), obj.updated_at]
214 214
  end
215 215

  
216
  def display_thumbnail(img, thumb_name = nil)
216
  def display_thumbnail(img, size_name = nil)
217 217
    return if img.nil?
218 218

  
219 219
    if not img.exists?
220 220
      return "<span class='error'>" + _("Missing Image !") + "</span>"
221 221
    end
222 222

  
223
    thumb = img.thumbnail(thumb_name)
223
    thumb = img.thumbnail(size_name)
224 224
    if thumb.nil?
225 225
      "<span class='error'>" + _("Missing Thumbnail !") + "</span>"
226 226
    else
227
      image_tag(img.public_filename(thumb_name))
227
      image_tag(img.public_filename(size_name))
228 228
    end
229 229
  end
230 230

  
app/models/artwork_step_image.rb
17 17
  attr_accessor :saved_attachment
18 18

  
19 19
  def thumbnail(size)
20
    return self if size.nil?
21

  
20 22
    thumb = self.artwork_step_thumbnails.find_by_thumbnail(size.to_s)
21 23
    if thumb.nil?
22 24
      regen_thumbnail(size)
......
27 29

  
28 30
  def regen_thumbnail(size_name)
29 31
    return unless self.exists?
32
    return if size_name.nil?
30 33

  
31 34
    size = attachment_options[:thumbnails][size_name]
32 35
    temp_file = create_temp_file

Also available in: Unified diff