From: Benoît Pin Date: Mon, 31 Mar 2014 07:53:28 +0000 (+0200) Subject: Prise en compte du paramètre thumb_size au moment de la fabrication. X-Git-Url: https://scm.cri.ensmp.fr/git/Portfolio.git/commitdiff_plain/b4892f9af387a40573b75c477365342de9a7ebc8?ds=inline;hp=2df8271f31182e728eba27ff51533aa1afe43c7d Prise en compte du paramètre thumb_size au moment de la fabrication. --- diff --git a/photo.py b/photo.py index c0c92c6..7cb8974 100755 --- a/photo.py +++ b/photo.py @@ -29,7 +29,7 @@ from Products.CMFCore.DynamicType import DynamicType from Products.CMFCore.CMFCatalogAware import CMFCatalogAware from Products.Photo.Photo import Photo as BasePhoto from Products.CMFDefault.DublinCore import DefaultDublinCoreImpl -from Products.CMFCore.utils import getToolByName +from Products.CMFCore.utils import getToolByName, getUtilityByInterfaceName from Products.Photo.cache import memoizedmethod from Products.DCWorkflow.utils import modifyRolesForPermission from interfaces import IPhoto @@ -214,4 +214,14 @@ class Photo(DynamicType, CMFCatalogAware, BasePhoto, DefaultDublinCoreImpl) : InitializeClass(Photo) -PhotoFactory = Factory(Photo) \ No newline at end of file +class _PhotoFactory(Factory) : + def __call__(self, *args, **kw): + if not kw.has_key('thumb_height') or not kw.has_key('thumb_width') : + utool = getUtilityByInterfaceName('Products.CMFCore.interfaces.IURLTool') + portal = utool.getPortalObject() + size = portal.getProperty('thumb_size') + kw.update({'thumb_height' : size, 'thumb_width' : size }) + return self._callable(*args, **kw) + + +PhotoFactory = _PhotoFactory(Photo) \ No newline at end of file diff --git a/skins/photo_layout_macros.pt b/skins/photo_layout_macros.pt index 16571dd..48b8040 100644 --- a/skins/photo_layout_macros.pt +++ b/skins/photo_layout_macros.pt @@ -102,7 +102,7 @@