page_content_marker.rb
787 Bytes
module Kanjai
class PageContentMarker < ActiveRecord::Base
belongs_to :page_content, optional: true
belongs_to :reference, polymorphic: true, optional: true
def get_file_path
"page-content-marker/#{self.id}/"
end
def get_marker_type(type_content)
page_content = self.page_content
template = page_content.page.page_template
subpart = template.template_parts.find_by_code(type_content)
p subpart.field_options
obj = subpart.field_options.select{|item| item[:name] == self.marker }.first
if obj
obj[:attributes]['type']
else
return nil
end
end
def self.image?(url)
ext = File.extname(url)
['.jpg', '.gif', '.jpeg', '.png', '.svg', '.webp'].include?(ext)
end
end
end