Module: Pageflow::FilesHelper
Constant Summary
RenderJsonHelper::ESCAPED_CHARS, RenderJsonHelper::ESCAPED_CHARS_REGEX
Instance Method Summary
collapse
#lookup_video_tag, #mobile_poster_image_div, #poster_image_tag, #video_file_non_js_link, #video_file_script_tag, #video_file_sources, #video_file_video_tag
#render_html_partial, #render_json_partial, #render_json_seed, #render_with_format, #sanitize_json
Instance Method Details
#file_dimensions(file) ⇒ Object
10
11
12
13
14
15
16
|
# File 'app/helpers/pageflow/files_helper.rb', line 10
def file_dimensions(file)
if file.width && file.height
"#{file.width} x #{file.height}px"
else
"-"
end
end
|
#file_duration(file) ⇒ Object
18
19
20
21
22
23
24
25
26
27
28
29
|
# File 'app/helpers/pageflow/files_helper.rb', line 18
def file_duration(file)
if file.duration_in_ms
total_seconds = file.duration_in_ms / 1000
seconds = total_seconds % 60
minutes = (total_seconds / 60) % 60
hours = total_seconds / (60 * 60)
format("%02d:%02d:%02d", hours, minutes, seconds)
else
"-"
end
end
|
6
7
8
|
# File 'app/helpers/pageflow/files_helper.rb', line 6
def file_format(file)
file.format.presence || '-'
end
|
#files_json_seeds(entry) ⇒ Object
31
32
33
34
35
36
37
38
39
40
41
42
|
# File 'app/helpers/pageflow/files_helper.rb', line 31
def files_json_seeds(entry)
inner = Pageflow.config.file_types.map do |file_type|
json = render_json_partial(partial: 'pageflow/editor/files/file',
collection: entry.find_files(file_type.model),
locals: {file_type: file_type},
as: :file)
%'"#{file_type.collection_name}": #{json}'
end.join(',')
"{#{inner}}".html_safe
end
|