Module: MnoEnterprise::ImageHelper

Included in:
InvoicePdf
Defined in:
app/helpers/mno_enterprise/image_helper.rb

Constant Summary collapse

IMAGES_LOCATION =
"/app/assets/images/mno_enterprise/"

Instance Method Summary collapse

Instance Method Details

#app_image_path(file_name) ⇒ Object

Build path and checks if the logo exists



22
23
24
25
# File 'app/helpers/mno_enterprise/image_helper.rb', line 22

def app_image_path(file_name)
  app_path = "#{Rails.root}#{IMAGES_LOCATION}#{file_name}"
  app_path if File.exists?(app_path)
end

#engine_image_path(file_name) ⇒ Object

Get engine’s logo and return it



28
29
30
# File 'app/helpers/mno_enterprise/image_helper.rb', line 28

def engine_image_path(file_name)
  "#{MnoEnterprise::Engine.root}#{IMAGES_LOCATION}#{file_name}"
end

#fit_imageObject



32
33
34
# File 'app/helpers/mno_enterprise/image_helper.rb', line 32

def fit_image
  'max-width: 150px; max-height: 150px;'
end

#main_logo_pathObject

Return the main-logo.png if exists otherwise get engine’s logo



16
17
18
19
# File 'app/helpers/mno_enterprise/image_helper.rb', line 16

def main_logo_path
  file_name = "main-logo.png"
  app_image_path(file_name) || engine_image_path(file_name)
end

#main_logo_white_bg_path(full_path = false) ⇒ Object

Helper method to easily access and select the images If full_path is true returns filename appended to the path If full_path is false returns filename Return the main-logo-whitebg.png if exists, otherwise get main-logo.png



10
11
12
13
# File 'app/helpers/mno_enterprise/image_helper.rb', line 10

def main_logo_white_bg_path(full_path=false)
  logo_path = app_image_path("main-logo-whitebg.png") || main_logo_path
  full_path ? logo_path : "mno_enterprise/#{File.basename(logo_path)}"
end