Use new extensions to generates images thumbnails handling SVG
authorThierry Florac <thierry.florac@onf.fr>
Tue, 19 Jun 2018 17:13:44 +0200
changeset 709 4f6cca33ed8b
parent 708 b84e4de0c0ba
child 710 c770464c85a3
Use new extensions to generates images thumbnails handling SVG
src/pyams_content/reference/pictograms/zmi/__init__.py
src/pyams_content/reference/pictograms/zmi/templates/pictogram-header.pt
--- a/src/pyams_content/reference/pictograms/zmi/__init__.py	Tue Jun 19 17:13:05 2018 +0200
+++ b/src/pyams_content/reference/pictograms/zmi/__init__.py	Tue Jun 19 17:13:44 2018 +0200
@@ -14,9 +14,6 @@
 
 
 # import standard library
-import sys
-
-from random import randint
 from uuid import uuid4
 
 # import interfaces
@@ -32,6 +29,7 @@
 
 # import packages
 from pyams_content.reference.pictograms import Pictogram
+from pyams_file.zmi.image import render_image
 from pyams_form.form import AJAXAddForm, ajax_config
 from pyams_i18n.column import I18nAttrColumn
 from pyams_pagelet.pagelet import pagelet_config
@@ -40,7 +38,6 @@
 from pyams_skin.viewlet.toolbar import ToolbarAction
 from pyams_utils.adapter import adapter_config
 from pyams_utils.traversing import get_parent
-from pyams_utils.url import absolute_url
 from pyams_viewlet.viewlet import viewlet_config
 from pyams_zmi.form import AdminDialogAddForm, AdminDialogEditForm
 from pyramid.httpexceptions import HTTPNotFound
@@ -142,8 +139,8 @@
     def getValue(self, obj):
         image = II18n(obj).query_attribute('image', request=self.request)
         if image:
-            timestamp = randint(0, sys.maxsize)
-            return '<img src="{0}?_={1}" />'.format(absolute_url(image, self.request, '++thumb++32x32'), timestamp)
+            return render_image(image, 32, 32, timestamp=True)
+        return '--'
 
 
 @adapter_config(name='name', context=(IPictogramTable, IAdminLayer, PictogramTableContentsTable), provides=IColumn)
--- a/src/pyams_content/reference/pictograms/zmi/templates/pictogram-header.pt	Tue Jun 19 17:13:05 2018 +0200
+++ b/src/pyams_content/reference/pictograms/zmi/templates/pictogram-header.pt	Tue Jun 19 17:13:44 2018 +0200
@@ -1,8 +1,8 @@
-<div i18n:domain="pyams_content">
-	<img class="padding-5"
-		 tal:define="image i18n:context.image"
-		 tal:attributes="src extension:absolute_url(image, '++thumb++32x32')" />
-	<span tal:define="header i18n:context.header"
+<div class="padding-5" i18n:domain="pyams_content">
+	<tal:var define="image i18n:context.image"
+			 condition="image"
+			 content="structure extension:thumbnail(image, 32, 'auto')" />
+	<span class="padding-left-5" tal:define="header i18n:context.header"
 		  i18n:translate="">Default header:
 		<strong i18n:name="header" tal:content="header or '--'" />
 	</span>