diff --git a/Products/CMFPlone/browser/search.py b/Products/CMFPlone/browser/search.py index a8c34129d6..8e396ed2ed 100644 --- a/Products/CMFPlone/browser/search.py +++ b/Products/CMFPlone/browser/search.py @@ -1,5 +1,6 @@ from DateTime import DateTime from plone.app.contentlisting.interfaces import IContentListing +from plone.app.layout.navigation.interfaces import INavigationRoot from plone.registry.interfaces import IRegistry from Products.CMFCore.utils import getToolByName from Products.CMFPlone.browser.navtree import getNavigationRoot @@ -249,27 +250,37 @@ def __call__(self): registry = queryUtility(IRegistry) length = registry.get('plone.search_results_description_length') + show_images = registry.get('plone.search_show_images') + if show_images: + image_scale = registry.get('plone.search_image_scale') + # image_scaling = getMultiAdapter((self.context, self.request), name='image_scale') + self.image_scaling = getMultiAdapter((INavigationRoot(self.context), self.request), name='image_scale') plone_view = getMultiAdapter( (self.context, self.request), name='plone') - registry = getUtility(IRegistry) view_action_types = registry.get( 'plone.types_use_view_action_in_listings', []) for item in batch: url = item.getURL() if item.portal_type in view_action_types: url = '%s/view' % url + img_tag = None + if show_images: + img_tag = self.get_image_tag(item, image_scale) items.append({ 'id': item.UID, 'title': item.Title, 'description': plone_view.cropText(item.Description, length), 'url': url, 'state': item.review_state if item.review_state else None, + 'img_tag': img_tag, }) return json.dumps({ 'total': len(results), 'items': items }) + def get_image_tag(self, item, image_scale): + return self.image_scaling.tag(item, "image", scale=image_scale) class SortOption: diff --git a/news/3489.feature b/news/3489.feature new file mode 100644 index 0000000000..4b029fb1f5 --- /dev/null +++ b/news/3489.feature @@ -0,0 +1,2 @@ +Added support for images in liveSearch results. +[agitator] \ No newline at end of file