mirror of
https://github.com/openSUSE/osem.git
synced 2026-08-18 14:11:10 +00:00
Places logo on a white background if image is smaller than the given
constrains.
Resizes the logo if image is larger than constrains.
Validation of presence of logo was moved cause file field wasn't getting
marked as required field ('*' thingy) in form.
`- if logo presence` was removed cause logo is mandatory field.
21 lines
968 B
Ruby
21 lines
968 B
Ruby
class Sponsor < ActiveRecord::Base
|
|
belongs_to :sponsorship_level
|
|
belongs_to :conference
|
|
has_attached_file :logo,
|
|
styles: { thumb: '100x100>',
|
|
first: '320x180>',
|
|
second: '320x150>',
|
|
others: '320x120>' },
|
|
# places logo on a white background to maintain size
|
|
convert_options: {
|
|
first: '-background white -gravity center -extent 320x180',
|
|
second: '-background white -gravity center -extent 320x150',
|
|
others: '-background white -gravity center -extent 320x120'
|
|
}
|
|
|
|
validates_attachment_content_type :logo,
|
|
content_type: [/jpg/, /jpeg/, /png/, /gif/],
|
|
size: { in: 0..500.kilobytes }
|
|
|
|
validates_presence_of :name, :website_url, :sponsorship_level, :logo
|
|
end
|