Updated video display
authorThierry Florac <thierry.florac@onf.fr>
Tue, 08 Sep 2015 16:22:46 +0200
changeset 3 4fe9ea97da5a
parent 2 5410acbcfb77
child 4 36c3db8c50a4
Updated video display
src/pyams_media/zmi/templates/video-thumbnail.pt
--- a/src/pyams_media/zmi/templates/video-thumbnail.pt	Tue Sep 08 16:21:33 2015 +0200
+++ b/src/pyams_media/zmi/templates/video-thumbnail.pt	Tue Sep 08 16:22:46 2015 +0200
@@ -10,9 +10,17 @@
 	<video
 		tal:define="href extension:absolute_url(context);
 					thumbnails extension:thumbnails(context);
+					conversions extension:conversions(context);
 					size thumbnails.get_image_size();"
-		tal:attributes="poster string:${href}/++thumb++${size[0]}x${size[1]}">
-		<source type="video/mp4"
-				tal:attributes="src href" />
+		tal:attributes="poster string:${href}/++thumb++${size[0]}x${size[1]}.png">
+		<tal:loop repeat="conversion conversions.get_conversions(order=('video/webm','video/mp4','video/x-flv'))">
+			<source type="video/mp4"
+					tal:define="media_width conversions.get_conversion_width(conversion.__name__);
+								video_type extension:video_type(conversion);"
+					tal:condition="video_type"
+					tal:attributes="type video_type;
+									src extension:absolute_url(conversion);
+									media 'all and (max-width: {0[0]}px)'.format(media_width) if media_width else None;" />
+		</tal:loop>
 	</video>
 </div>