Class: Decidim::Attachment
- Inherits:
-
ApplicationRecord
- Object
- ActiveRecord::Base
- ApplicationRecord
- Decidim::Attachment
- Defined in:
- app/models/decidim/attachment.rb
Overview
Attachment can be any type of document or images related to a partcipatory process.
Instance Method Summary collapse
-
#big_url ⇒ Object
The URL to download the a big version of the file.
-
#document? ⇒ Boolean
Whether this attachment is a document or not.
-
#file_type ⇒ Object
Which kind of file this is.
-
#photo? ⇒ Boolean
Whether this attachment is a photo or not.
-
#thumbnail_url ⇒ Object
The URL to download the thumbnail of the file.
Instance Method Details
#big_url ⇒ Object
The URL to download the a big version of the file. Only works with images.
Returns String.
53 54 55 56 |
# File 'app/models/decidim/attachment.rb', line 53 def big_url return unless photo? file.big.url end |
#document? ⇒ Boolean
Whether this attachment is a document or not.
Returns Boolean.
26 27 28 |
# File 'app/models/decidim/attachment.rb', line 26 def document? !photo? end |
#file_type ⇒ Object
Which kind of file this is.
Returns String.
33 34 35 |
# File 'app/models/decidim/attachment.rb', line 33 def file_type file.url&.split(".")&.last&.downcase end |
#photo? ⇒ Boolean
Whether this attachment is a photo or not.
Returns Boolean.
19 20 21 |
# File 'app/models/decidim/attachment.rb', line 19 def photo? @photo ||= content_type.start_with? "image" end |
#thumbnail_url ⇒ Object
The URL to download the thumbnail of the file. Only works with images.
Returns String.
45 46 47 48 |
# File 'app/models/decidim/attachment.rb', line 45 def thumbnail_url return unless photo? file.thumbnail.url end |