Skip to content

Commit

Permalink
media file previews: 30% rule for video files
Browse files Browse the repository at this point in the history
  • Loading branch information
eins78 committed Dec 7, 2015
1 parent 99def4d commit 2b2665b
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion app/models/media_file_modules/previews.rb
Expand Up @@ -13,7 +13,17 @@ def get_preview(size = nil, type = nil)
if type
_previews = _previews.where(:content_type => type)
end
_previews.first

# If thumbnail for video is requested and there is more than one available:
if (_previews.length > 1 \
&& _previews.first.media_file.media_type == 'video' \
&& type == 'image/jpeg')
# take one from around 30% of the list
position = (_previews.length.to_f/10*3).to_i
_previews[position]
else # otherwise return first preview:
_previews.first
end
end

def previews_creatable?
Expand Down

0 comments on commit 2b2665b

Please sign in to comment.