[Git][noosfero/noosfero][master] video plugin: Set default thumbnail dimensions to avoid crash with nil value on gallery page

Larissa Reis gitlab at mg.gitlab.com
Wed Jul 13 00:07:41 BRT 2016


Larissa Reis pushed to branch master at Noosfero / noosfero


Commits:
4f262d0c by Larissa Reis at 2016-07-12T18:40:00-03:00
video plugin: Set default thumbnail dimensions to avoid crash with nil value on gallery page

- - - - -


2 changed files:

- plugins/video/lib/video_plugin/video.rb
- plugins/video/test/unit/video_test.rb


Changes:

=====================================
plugins/video/lib/video_plugin/video.rb
=====================================
--- a/plugins/video/lib/video_plugin/video.rb
+++ b/plugins/video/lib/video_plugin/video.rb
@@ -12,8 +12,8 @@ class VideoPlugin::Video < Article
   settings_items :video_format,      :type => :string
   settings_items :video_id,          :type => :string
   settings_items :video_thumbnail_url,    :type => :string, :default => '/plugins/video/images/video_generic_thumbnail.jpg'
-  settings_items :video_thumbnail_width,  :type=> :integer
-  settings_items :video_thumbnail_height, :type=> :integer
+  settings_items :video_thumbnail_width,  :type=> :integer, :default => 239
+  settings_items :video_thumbnail_height, :type=> :integer, :default => 210
   settings_items :video_duration, :type=> :integer, :default => 0
 
   attr_accessible :video_url
@@ -35,14 +35,14 @@ class VideoPlugin::Video < Article
   def self.description
     _('Display embedded videos.')
   end
-  
+
   def is_youtube?
     VideoPlugin::Video.is_youtube?(self.video_url)
   end
 
   def is_vimeo?
     VideoPlugin::Video.is_vimeo?(self.video_url)
-  end  
+  end
 
   include ActionView::Helpers::TagHelper
   def to_html(options={})


=====================================
plugins/video/test/unit/video_test.rb
=====================================
--- a/plugins/video/test/unit/video_test.rb
+++ b/plugins/video/test/unit/video_test.rb
@@ -46,6 +46,11 @@ class VideoTest < ActiveSupport::TestCase
     assert_equal thumbnail_fitted_height, @video.thumbnail_fitted_height
   end
 
+  should "have dimensions of default thumbnail" do
+    assert @video.video_thumbnail_height.present? && @video.video_thumbnail_height > 0
+    assert @video.video_thumbnail_width.present? && @video.video_thumbnail_width > 0
+  end
+
   should "show a no_browser_support_message" do
     assert_equal @video.no_browser_support_message, '<p class="vjs-no-js">To view this video please enable JavaScript, and consider upgrading to a web browser that <a href="http://videojs.com/html5-video-support/" target="_blank">supports HTML5 video</a></p>'
   end



View it on GitLab: https://gitlab.com/noosfero/noosfero/commit/4f262d0ce11c4a29c031f1efea9ceb0bcdba9700
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://listas.softwarelivre.org/pipermail/noosfero-dev/attachments/20160713/746774a0/attachment-0001.html>


More information about the Noosfero-dev mailing list