Closed frapell closed 7 months ago
I have included a test that triggers the bug. I am not sure how to properly fix this... I don't think we want to import behaviors such as https://github.com/plone/plone.app.contenttypes/blob/master/plone/app/contenttypes/behaviors/leadimage.py in here?
@frapell How about, get the image attribute like it does currently, but then add a check that the value is an instance of NamedImage?
@davisagli Yeah, it is either that or maybe adding image
to the list of reserved words... what about checking if it provides plone.namedfile.interfaces.IImage
?
@frapell the IImage interface check should work
So to implement the "icon" for a content, a NamedImage or an object implementing the plone.namedfile.interfaces.IImage
interface should be returned when calling 'image' (attribute or function) on it?
@yurj I am not sure why this indexer is called getIcon
while it should really be called hasImage
or something like that... it will only return True or False if the item has an image. You can see the referenced PR in the comment (https://github.com/plone/Products.CMFPlone/issues/1226) it is almost 10 years old, so you need to dig some deeper to find the origin of it, maybe at some point it was used for icons.
Content icons these days are managed through css AFAIK...
The issue is happening here https://github.com/plone/Products.CMFPlone/blob/72ec2cad51e3096b043f79b1777f6e452f83afdf/Products/CMFPlone/CatalogTool.py#L226-L237
In order to see the problem:
At this point, if you go check the indexed folder from step 1 (/Plone/test-folder) you will notice that the
getIcon
metadata is True.This causes issues, such as https://github.com/plone/plone.namedfile/issues/156
@davisagli provided a bit more context in this other issue, however I believe this must be fixed here, and have
getIcon
to properly return True only when the indexed item does have an image.