Skip to content

Commit

Permalink
Make use of plone.namedfile's tag() function to generate image tags
Browse files Browse the repository at this point in the history
  • Loading branch information
Diederik Veeze authored and mauritsvanrees committed Feb 16, 2017
1 parent 12f85bd commit b025b48
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 22 deletions.
4 changes: 3 additions & 1 deletion CHANGES.rst
Expand Up @@ -11,7 +11,9 @@ Breaking changes:

New features:

- *add item here*
- Make use of plone.namedfile's tag() function to generate image tags.
Part of plip 1483.
[didrix]

Bug fixes:

Expand Down
7 changes: 3 additions & 4 deletions plone/app/portlets/portlets/navigation_recurse.pt
Expand Up @@ -29,10 +29,9 @@
<a tal:attributes="href python:item_remote_url if use_remote_url else item_url;
title node/Description;
class string:${item_class}${li_class}${li_extr_class}${li_folder_class} ${item_type_class}">
<img class="image-icon"
tal:condition="has_thumb"
tal:attributes="src thumb_url;
alt node/Description">
<img tal:condition="has_thumb"
tal:define="obj node/item/getObject; images obj/@@images"
tal:replace="structure python:images.scale('image', scale='icon').tag(css_class='image-icon')">
<span tal:replace="node/Title">Selected Item Title</span>
</a>

Expand Down
8 changes: 3 additions & 5 deletions plone/app/portlets/portlets/news.pt
Expand Up @@ -25,11 +25,9 @@
class="tile"
tal:attributes="href obj/getURL;
title obj/Description">
<img class="image-icon"
tal:define="getIcon python:obj.getURL()+'/@@images/image/icon'"
tal:condition="python: obj.getIcon"
tal:attributes="href obj/getURL;
src string:$getIcon">
<img tal:condition="python: obj.getIcon"
tal:define="awake_obj obj/getObject; icon awake_obj/@@images|nothing"
tal:replace="structure python:icon.scale('image', scale='icon').tag(css_class='image-icon')" />
<span tal:replace="obj/pretty_title_or_id">
Plone 5.1 announced!
</span>
Expand Down
8 changes: 3 additions & 5 deletions plone/app/portlets/portlets/recent.pt
Expand Up @@ -29,11 +29,9 @@
tal:attributes="href string:${obj/getURL}/view;
title obj/Description;
class string:$item_wf_state_class tile $item_class">
<img class="image-icon"
tal:define="getIcon python:obj.getURL()+'/@@images/image/icon'"
tal:condition="python: obj.getIcon"
tal:attributes="href obj/getURL;
src string:$getIcon">
<img tal:condition="python: obj.getIcon"
tal:define="awake_obj obj/getObject; icon awake_obj/@@images|nothing"
tal:replace="structure python:icon.scale('image', scale='icon').tag(css_class='image-icon')" />
<span tal:content="obj/pretty_title_or_id">
Title
</span>
Expand Down
7 changes: 2 additions & 5 deletions plone/app/portlets/portlets/review.pt
Expand Up @@ -27,11 +27,8 @@
tal:attributes="href string:${o/path}/view;
title o/description;
class string:$review_state_class tile $item_class">
<img class="image-icon"
tal:define="getIcon string:${o/path}/@@images/image/icon"
tal:condition="o/hasImage"
tal:attributes="href string:${o/path}/view;
src string:$getIcon">
<img tal:condition="o/hasImage"
tal:replace="structure python:o['images'].scale('image', scale='icon').tag(css_class='image-icon')" />
<span tal:replace="o/title">
Title
</span>
Expand Down
6 changes: 4 additions & 2 deletions plone/app/portlets/portlets/review.py
Expand Up @@ -76,7 +76,8 @@ def _data(self):
creator_name = creator.getProperty('fullname', '') or creator_id
else:
creator_name = creator_id
hasImage = True if getattr(obj,'image',None) else False
hasImage = True if getattr(obj, 'image', None) else False
images = obj.restrictedTraverse('@@images') if hasImage else None
items.append(dict(
path=obj.absolute_url(),
title=obj.pretty_title_or_id(),
Expand All @@ -86,7 +87,8 @@ def _data(self):
review_state=review_state,
review_state_class='state-%s ' % norm(review_state),
mod_date=toLocalizedTime(obj.ModificationDate()),
hasImage = hasImage,
hasImage=hasImage,
images=images,
))
return items

Expand Down

0 comments on commit b025b48

Please sign in to comment.