thumb and medium image styles"
This commit is contained in:
parent
52b5ecb622
commit
8d40c03cce
1 changed files with 6 additions and 7 deletions
|
@ -6,9 +6,8 @@ class Attachment < ApplicationRecord
|
||||||
styles: lambda { |a|
|
styles: lambda { |a|
|
||||||
if a.instance.image?
|
if a.instance.image?
|
||||||
{
|
{
|
||||||
small: 'x200>',
|
thumb: 'x128#',
|
||||||
medium: 'x300>',
|
medium: 'x320>'
|
||||||
large: 'x400>'
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{}
|
{}
|
||||||
|
@ -18,19 +17,19 @@ class Attachment < ApplicationRecord
|
||||||
validates_attachment_content_type :file, content_type: Attachable.allowed_types
|
validates_attachment_content_type :file, content_type: Attachable.allowed_types
|
||||||
|
|
||||||
def image?
|
def image?
|
||||||
file.instance.file_content_type =~ %r{\Aimage}
|
Attachable.image_types.include(file.instance.file_content_type)
|
||||||
end
|
end
|
||||||
|
|
||||||
def audio?
|
def audio?
|
||||||
file.instance.file_content_type ~= %r{\Aaudio}
|
Attachable.audio_types.include(file.instance.file_content_type)
|
||||||
end
|
end
|
||||||
|
|
||||||
def text?
|
def text?
|
||||||
file.instance.file_content_type ~= %r{\Atext}
|
Attachable.text_types.include(file.instance.file_content_type)
|
||||||
end
|
end
|
||||||
|
|
||||||
def pdf?
|
def pdf?
|
||||||
file.instance.file_content_type == 'application/pdf'
|
Attachable.pdf_types.include(file.instance.file_content_type)
|
||||||
end
|
end
|
||||||
|
|
||||||
def document?
|
def document?
|
||||||
|
|
Loading…
Add table
Reference in a new issue