Skip to content

Commit

Permalink
Refactored solution to issue #239
Browse files Browse the repository at this point in the history
  • Loading branch information
cleberjsantos committed Aug 6, 2013
1 parent 3aeef44 commit 361e7a9
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
9 changes: 7 additions & 2 deletions src/collective/cover/tiles/collection.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,10 +158,15 @@ def get_configured_fields(self):
return results

def thumbnail(self, item):
tile_conf = self.get_tile_configuration()
image_conf = tile_conf.get('image', None)
scales = item.restrictedTraverse('@@images')
try:
scale = [i['scale'].split(' ')[0] for i in self.get_configured_fields() if i['id'] == 'image'][0]
return scales.scale('image', scale)
if image_conf:
scaleconf = image_conf['imgsize']
# scale string is something like: 'mini 200:200'
scale = scaleconf.split(' ')[0] # we need the name only: 'mini'
return scales.scale('image', scale)
except:
return None

Expand Down
3 changes: 2 additions & 1 deletion src/collective/cover/tiles/templates/collection.pt
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@
<img style="float: left; margin: 0 1em 0.5em 0;"
tal:attributes="src thumbnail/url;
width thumbnail/width;
height thumbnail/height" />
height thumbnail/height;
alt obj/Description|obj/Title" />
</a>
</tal:image>

Expand Down

0 comments on commit 361e7a9

Please sign in to comment.