Added timestamp to video thumbnails
authorThierry Florac <thierry.florac@onf.fr>
Mon, 11 Dec 2017 15:29:06 +0100
changeset 62 104d1289c2ad
parent 61 f83e22210fda
child 63 b53d7425076d
Added timestamp to video thumbnails
src/pyams_media/zmi/templates/video-preview.pt
src/pyams_media/zmi/templates/video-thumbnail.pt
src/pyams_media/zmi/video.py
--- a/src/pyams_media/zmi/templates/video-preview.pt	Fri Oct 13 10:21:11 2017 +0200
+++ b/src/pyams_media/zmi/templates/video-preview.pt	Mon Dec 11 15:29:06 2017 +0100
@@ -10,7 +10,7 @@
 					thumbnails extension:thumbnails(context);
 					conversions extension:conversions(context);
 					size thumbnails.get_image_size();"
-		tal:attributes="poster string:${href}/++thumb++${size[0]}x${size[1]}.png">
+		tal:attributes="poster string:${href}/++thumb++${size[0]}x${size[1]}.png?_=${view/timestamp}">
 		<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__);
--- a/src/pyams_media/zmi/templates/video-thumbnail.pt	Fri Oct 13 10:21:11 2017 +0200
+++ b/src/pyams_media/zmi/templates/video-thumbnail.pt	Mon Dec 11 15:29:06 2017 +0100
@@ -11,7 +11,7 @@
 					thumbnails extension:thumbnails(context);
 					conversions extension:conversions(context);
 					size thumbnails.get_image_size();"
-		tal:attributes="poster string:${href}/++thumb++${size[0]}x${size[1]}.png">
+		tal:attributes="poster string:${href}/++thumb++${size[0]}x${size[1]}.png?_=${view/timestamp}">
 		<tal:loop repeat="conversion conversions.get_conversions(order=('video/webm','video/mp4','video/x-flv'))">
 			<tal:if define="video_type extension:video_type(conversion);"
 					condition="video_type">
--- a/src/pyams_media/zmi/video.py	Fri Oct 13 10:21:11 2017 +0200
+++ b/src/pyams_media/zmi/video.py	Mon Dec 11 15:29:06 2017 +0100
@@ -14,6 +14,7 @@
 
 
 # import standard library
+from datetime import datetime
 from decimal import Decimal
 
 # import interfaces
@@ -63,6 +64,10 @@
 class VideoPreviewViewletsPrefix(Viewlet):
     """Video preview viewlets prefix"""
 
+    @property
+    def timestamp(self):
+        return datetime.utcnow().timestamp()
+
 
 #
 # Video thumbnail
@@ -151,6 +156,10 @@
 class VideoThumbnailViewletsPrefix(Viewlet):
     """Video thumbnail edit form viewlets prefix"""
 
+    @property
+    def timestamp(self):
+        return datetime.utcnow().timestamp()
+
 
 @adapter_config(context=(IVideo, IAdminLayer, VideoThumbnailEditForm), provides=IFormHelp)
 class VideoThumbnailEditFormHelpAdapter(FormHelp):