The lead image in Plone 5 usually comes from a viewlet, I think.
if you want it in your view, you can probably use something like (use your desired scale instead of context/leadimagesize and drop and leadsize and leadsize != 'none'):
IMO, this is another example of something that was not very well though when designed; let me explain: what if I want to directly provide an image field in my content type without having to depend on the behavior?
and this is not a rare case: we have 2 different content types (News Article and Photo Gallery) that are containers and we implement the lead image as the first image in the container:
I agree. I've always thought the image representation of a content in a listing was a little restrictive. Perhaps there should be a generic adapter or way to ask content to provide an image representation. then different behaviours could implement how they want.
def lead_image(self):
"""Return lead image information, if present. We try to guess
the information based on field names as it's useless to try
to deal with the ILeadImage interface.
:returns: lead image information
:rtype: dict or None
"""
image = getattr(self.context, 'image', None)
if image is None:
return None # no "image" field
if not isinstance(image, NamedBlobImage):
return None # not a real image
url = '{0}/@@download/image/{1}'.format(
self.context.absolute_url(), image.filename)
caption = getattr(self.context, 'image_caption', None)
width, height = image.getImageSize()
return dict(url=url, caption=caption, width=width, height=height)