Commit 657bcc2e authored by Jérome Perrin's avatar Jérome Perrin

VideoField: make valid HTML5 regarding preload

Unlike other attributes managed in video field, preload [1] is not a
boolean attribute, so setting preload="preload" was invalid HTML5.

On the field, we can only configure video_preload as a boolean
attribute, setting preload="auto" when true and not setting preload when
False seems the closest meaning of True/False.

[1] https://html.spec.whatwg.org/multipage/media.html#attr-media-preload
parent 8e99c75b
......@@ -94,7 +94,7 @@ class VideoWidget(Widget.TextWidget):
if field.get_value('video_loop'):
extra_kw['loop']='loop'
if field.get_value('video_preload'):
extra_kw['preload']='preload'
extra_kw['preload']='auto'
return Widget.render_element("video",
src=value,
extra=field.get_value('extra'),
......
......@@ -43,7 +43,7 @@ class TestVideoField(ERP5TypeTestCase):
def test_render_view(self):
self.field.values['default'] = 'Video content'
self.assertEqual('<video preload="preload" src="Video content" controls="controls" height="85" width="160" >Your browser does not support video tag.</video>', \
self.assertEqual('<video preload="auto" src="Video content" controls="controls" height="85" width="160" >Your browser does not support video tag.</video>', \
self.field.render_view(value='Video content'))
self.field.values['video_preload'] = False
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment