Class: Guts::Medium

Inherits:
ApplicationRecord show all
Includes:
MultisiteScopeConcern
Defined in:
app/models/guts/medium.rb

Overview

Medium model which utilizes PaperClip

Constant Summary collapse

CONTENT_TYPE_REGEX =

Regex used for sizing_only_images

%r{^(image|(x-)?application)/(x-png|pjpeg|jpeg|jpg|png|gif)$}i

Instance Method Summary collapse

Instance Method Details

#default_titleObject

Creates a title based on the file name if no title was entered



35
36
37
# File 'app/models/guts/medium.rb', line 35

def default_title
  self[:title] = self[:file_file_name] if self[:title].blank?
end

#image?Boolean|Nil

Determine if the file is an image and can be resized by Paperclip



29
30
31
# File 'app/models/guts/medium.rb', line 29

def image?
  !(self[:file_content_type] =~ CONTENT_TYPE_REGEX).nil?
end