Use timestamp in images URLs
authorThierry Florac <thierry.florac@onf.fr>
Tue, 03 Jul 2018 15:19:50 +0200
changeset 146 6e4da3ad6a67
parent 145 a39e0e6bb64b
child 147 7fb2efbf0b63
Use timestamp in images URLs
src/pyams_portal/portlets/image/skin/image.pt
src/pyams_portal/portlets/image/zmi/preview.pt
--- a/src/pyams_portal/portlets/image/skin/image.pt	Mon Jul 02 17:24:48 2018 +0200
+++ b/src/pyams_portal/portlets/image/skin/image.pt	Tue Jul 03 15:19:50 2018 +0200
@@ -4,11 +4,12 @@
 					image_url extension:absolute_url(image);
 					slot_config view.slot_configuration;
 					slot_width slot_config.get_width();
-					base_width 100 / 12;">
+					base_width 100 / 12;
+					timestamp extension:timestamp(image);">
 		<tal:var define="width slot_width['lg']">
 			<source media="(min-width: 1200px)"
 					tal:condition="width"
-					tal:attributes="srcset string:${image_url}/++thumb++lg:w1200 1200w, ${image_url}/++thumb++lg:w512 512w, ${image_url}/++thumb++lg:w256 256w, ${image_url}/++thumb++lg:w128 128w;
+					tal:attributes="srcset string:${image_url}/++thumb++lg:w1200?_=${timestamp} 1200w, ${image_url}/++thumb++lg:w512?_=${timestamp} 512w, ${image_url}/++thumb++lg:w256?_=${timestamp} 256w, ${image_url}/++thumb++lg:w128?_=${timestamp} 128w;
 									sizes string:${round(base_width * width)}vw" />
 			<source media="(min-width: 1200px)"
 					srcset="/--static--/pyams_default_theme/img/dot.png"
@@ -18,7 +19,7 @@
 		<tal:var define="width slot_width['md']">
 			<source media="(min-width: 992px)"
 					tal:condition="width"
-					tal:attributes="srcset string:${image_url}/++thumb++md:w992 992w, ${image_url}/++thumb++md:w512 512w, ${image_url}/++thumb++md:w256 256w, ${image_url}/++thumb++md:w128 128w;
+					tal:attributes="srcset string:${image_url}/++thumb++md:w992?_=${timestamp} 992w, ${image_url}/++thumb++md:w512?_=${timestamp} 512w, ${image_url}/++thumb++md:w256?_=${timestamp} 256w, ${image_url}/++thumb++md:w128?_=${timestamp} 128w;
 									sizes string:${round(base_width * width)}vw" />
 			<source media="(min-width: 992px)"
 					srcset="/--static--/pyams_default_theme/img/dot.png"
@@ -28,7 +29,7 @@
 		<tal:var define="width slot_width['sm']">
 			<source media="(min-width: 768px)"
 					tal:condition="width"
-					tal:attributes="srcset string:${image_url}/++thumb++sm:w768 768w, ${image_url}/++thumb++sm:w512 512w, ${image_url}/++thumb++sm:w256 256w, ${image_url}/++thumb++sm:w128 128w;
+					tal:attributes="srcset string:${image_url}/++thumb++sm:w768?_=${timestamp} 768w, ${image_url}/++thumb++sm:w512?_=${timestamp} 512w, ${image_url}/++thumb++sm:w256?_=${timestamp} 256w, ${image_url}/++thumb++sm:w128?_=${timestamp} 128w;
 									sizes string:${round(base_width * width)}vw" />
 			<source media="(min-width: 768px)"
 					srcset="/--static--/pyams_default_theme/img/dot.png"
@@ -38,7 +39,7 @@
 		<tal:var define="width slot_width['xs']">
 			<source media="(max-width: 767px)"
 					tal:condition="width"
-					tal:attributes="srcset string:${image_url}/++thumb++xs:w768 768w, ${image_url}/++thumb++xs:w512 512w, ${image_url}/++thumb++xs:w256 256w, ${image_url}/++thumb++xs:w128 128w;
+					tal:attributes="srcset string:${image_url}/++thumb++xs:w768?_=${timestamp} 768w, ${image_url}/++thumb++xs:w512?_=${timestamp} 512w, ${image_url}/++thumb++xs:w256?_=${timestamp} 256w, ${image_url}/++thumb++xs:w128?_=${timestamp} 128w;
 									sizes string:${round(base_width * width)}vw" />
 			<source media="(max-width: 767px)"
 					srcset="/--static--/pyams_default_theme/img/dot.png"
--- a/src/pyams_portal/portlets/image/zmi/preview.pt	Mon Jul 02 17:24:48 2018 +0200
+++ b/src/pyams_portal/portlets/image/zmi/preview.pt	Tue Jul 03 15:19:50 2018 +0200
@@ -8,13 +8,14 @@
 					   slot_width slot_config.get_width();
 					   base_width 100 / 12;
 					   thumbnails extension:thumbnails(image);
-					   target python:thumbnails.get_thumbnail('800x600');"
+					   target python:thumbnails.get_thumbnail('800x600');
+					   timestamp extension:timestamp(image);"
 		   tal:attributes="href extension:absolute_url(target)">
 			<picture>
 				<tal:var define="width slot_width['lg']">
 					<source media="(min-width: 1200px)"
 							tal:condition="width"
-							tal:attributes="srcset string:${image_url}/++thumb++lg:w1200 1200w, ${image_url}/++thumb++lg:w512 512w, ${image_url}/++thumb++lg:w256 256w, ${image_url}/++thumb++lg:w128 128w;
+							tal:attributes="srcset string:${image_url}/++thumb++lg:w1200?_=${timestamp} 1200w, ${image_url}/++thumb++lg:w512?_=${timestamp} 512w, ${image_url}/++thumb++lg:w256?_=${timestamp} 256w, ${image_url}/++thumb++lg:w128?_=${timestamp} 128w;
 											sizes string:${round(base_width * width)}vw" />
 					<source media="(min-width: 1200px)"
 							srcset="/--static--/pyams_default_theme/img/dot.png"
@@ -24,7 +25,7 @@
 				<tal:var define="width slot_width['md']">
 					<source media="(min-width: 992px)"
 							tal:condition="width"
-							tal:attributes="srcset string:${image_url}/++thumb++md:w992 992w, ${image_url}/++thumb++md:w512 512w, ${image_url}/++thumb++md:w256 256w, ${image_url}/++thumb++md:w128 128w;
+							tal:attributes="srcset string:${image_url}/++thumb++md:w992?_=${timestamp} 992w, ${image_url}/++thumb++md:w512?_=${timestamp} 512w, ${image_url}/++thumb++md:w256?_=${timestamp} 256w, ${image_url}/++thumb++md:w128?_=${timestamp} 128w;
 											sizes string:${round(base_width * width)}vw" />
 					<source media="(min-width: 992px)"
 							srcset="/--static--/pyams_default_theme/img/dot.png"
@@ -34,7 +35,7 @@
 				<tal:var define="width slot_width['sm']">
 					<source media="(min-width: 768px)"
 							tal:condition="width"
-							tal:attributes="srcset string:${image_url}/++thumb++sm:w768 768w, ${image_url}/++thumb++sm:w512 512w, ${image_url}/++thumb++sm:w256 256w, ${image_url}/++thumb++sm:w128 128w;
+							tal:attributes="srcset string:${image_url}/++thumb++sm:w768?_=${timestamp} 768w, ${image_url}/++thumb++sm:w512?_=${timestamp} 512w, ${image_url}/++thumb++sm:w256?_=${timestamp} 256w, ${image_url}/++thumb++sm:w128?_=${timestamp} 128w;
 											sizes string:${round(base_width * width)}vw" />
 					<source media="(min-width: 768px)"
 							srcset="/--static--/pyams_default_theme/img/dot.png"
@@ -44,7 +45,7 @@
 				<tal:var define="width slot_width['xs']">
 					<source media="(max-width: 767px)"
 							tal:condition="width"
-							tal:attributes="srcset string:${image_url}/++thumb++xs:w768 768w, ${image_url}/++thumb++xs:w512 512w, ${image_url}/++thumb++xs:w256 256w, ${image_url}/++thumb++xs:w128 128w;
+							tal:attributes="srcset string:${image_url}/++thumb++xs:w768?_=${timestamp} 768w, ${image_url}/++thumb++xs:w512?_=${timestamp} 512w, ${image_url}/++thumb++xs:w256?_=${timestamp} 256w, ${image_url}/++thumb++xs:w128?_=${timestamp} 128w;
 											sizes string:${round(base_width * width)}vw" />
 					<source media="(max-width: 767px)"
 							srcset="/--static--/pyams_default_theme/img/dot.png"