I have two classes, one which manages the "child" images and one for the "parent" images.
In the parent image class I have:
class Photo < ActiveRecord::Base
has_attachment :content_type => :image,
:storage => :file_system,
:size => 1..5.megabytes,
:thumbnails => { :thumb => 'c100x100' },
:thumbnail_class => ChildPhoto,
:path_prefix => "Photos"
validates_as_attachment
end
And in the child class:
class ChildPhoto < ActiveRecord::Base
has_attachment :content_type => :image,
:storage => :file_system,
:path_prefix => "Photos",
validates_as_attachment
end
I've removed the :belongs_to stuff because mine is quite funky and gets in the way of reading :)
Anyways, this is code for a friend's photography portfolio and so obviously the images can be quite large when first uploaded. The issue, though, is that I left the size parameter as the default for the child class as I figured thumbnails wouldn't be very large at all. However, the image size is checked before the resize operation and so the child class throws its toys out of the pram because it has an image that is larger than it is expecting. Is this expected behavior? The solution, obviously, is to also apply the :size option to the ChildImage class, but this feels wrong to me...
I have two classes, one which manages the "child" images and one for the "parent" images.
In the parent image class I have: class Photo < ActiveRecord::Base has_attachment :content_type => :image, :storage => :file_system, :size => 1..5.megabytes, :thumbnails => { :thumb => 'c100x100' }, :thumbnail_class => ChildPhoto, :path_prefix => "Photos"
And in the child class: class ChildPhoto < ActiveRecord::Base has_attachment :content_type => :image, :storage => :file_system, :path_prefix => "Photos",
I've removed the :belongs_to stuff because mine is quite funky and gets in the way of reading :)
Anyways, this is code for a friend's photography portfolio and so obviously the images can be quite large when first uploaded. The issue, though, is that I left the size parameter as the default for the child class as I figured thumbnails wouldn't be very large at all. However, the image size is checked before the resize operation and so the child class throws its toys out of the pram because it has an image that is larger than it is expecting. Is this expected behavior? The solution, obviously, is to also apply the :size option to the ChildImage class, but this feels wrong to me...