-
-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
volto.preview_image_link
does not work OOTB
#141
Comments
We have custom serializers for this in every single project, even in TBH, I implemented that under the assumption that the serialization that This is the type: export interface PossibleImageFields {
image?:
| PreviewImage
| {
image: PreviewImage;
};
preview_image?: PreviewImage;
preview_image_link?: Content & { image: PreviewImage };
}
type PossibleImageFieldsKeys = keyof PossibleImageFields;
type PossibleImageFieldsUnion = PossibleImageFields[PossibleImageFieldsKeys];
// Being the result:
type PossibleImageFieldsUnion = PreviewImage | {
image: PreviewImage;
} | (Content & {
image: PreviewImage;
}) | undefined and the summary would be completely different. Let's model also all possible responses in TS, this way we will have a better understanding of what's going on, also start unifying things. |
@sneridagh There are a few different cases and I'm a bit confused about which serialization you're talking about here. (Serialization of the image_preview_link field when you get the page from the content service? Serialization of the preview_image_link in the image_scales field when the page's summary serialization appears in a listing? Something else?) Please specify the URL where you got the serialization that you showed in this issue's description. |
The snippet above is from the page object content serialization, what's inside of preview_image_link field in the main content endpoint. |
Which seems to me like a summary of the item? |
@davisagli Btw, it can be easy reproduced in demo.plone.org |
@sneridagh There it comes from the relation field serializer, which uses the summary serializer: https://github.com/plone/plone.restapi/blob/main/src/plone/restapi/serializer/relationfield.py#L23 The summary serializer adapts its context to IContentListingObject. Normally its context is a catalog brain, and image_scales is available from the catalog metadata. But when it's used by the relation field serializer, the context is a full object, so the IContentListingObject adapter is RealContentListingObject which does not have access to the image scales from the catalog. For our client project we implemented an override of RealContentListingObject which adds support for getting the image_scales:
Like the comment says, we should backport that to the base class in plone.app.contentlisting. |
I'm trying to get the
preview_image_link
workable, but it seems that it is not working.The scales never get into the serialization, I can't pinpoint why.
Steps to reproduce:
1.- Add the behavior
volto.preview_image_link
to theDocument
content type, remove the normalpreview_image
field to avoid confusions2.- Add an image
3.- Select the image in the Preview Image field
4.- Save
The serialization:
The serializer seems to be passing the PersistentDict of the scales to the index and the metadata fields are present in the catalog for that object.
However, when the summary serializer kicks in, the value somehow is null for both. This is correct and being called:
https://github.com/plone/plone.volto/blob/main/src/plone/volto/summary.py#L9-L10
/cc @davisagli @ericof
The text was updated successfully, but these errors were encountered: