plone / volto

React-based frontend for the Plone Content Management System
https://demo.plone.org/
MIT License
481 stars 653 forks source link

On image upload the download link is absolute and relative on the same image selected using the Object Browser #6160

Open ichim-david opened 4 months ago

ichim-david commented 4 months ago

In Volto when you add an image block and you upload an image, after you inspect the data information, within the image scales you will see that the download link is set with absolute value as seen in this image: volto-image-download-link-uploaded

If I add another image block and select using the Object browser the same image the download url no longer contains the absolute path as seen in this screenshot: volto-image-download-link-selected

I would expect the same url behavior to happen when uploading as when you select the image that was already uploaded without the site path hardcode.

It should be investigated if the problem arrives from Volto and plone.restapi itself or if it is a combination of faults.

davisagli commented 3 months ago

The first one comes from the full content serializer and the second one comes from the summary serializer (from the catalog). The paths have to be stored in the catalog without the hostname, but I think we should update the serializer to convert them back to full URLs which are easier to use on the frontend. The volto Image component already handles both relative and absolute URLs, so it should not be breaking.

ichim-david commented 3 months ago

@davisagli I think the opposite, we should use the url without the host name. We were having issues with image referencing when copying the dB from the main site to a staging and the full path meant no proper display of images. Since image blocks indeed tries to flatten to url which is relative it's easy to have the relative directly.

We were hit by another issues which I added dealing with razzle public path setting where the urls appeared with like like backend:8080 but yeah I that's another discussion

davisagli commented 3 months ago

@ichim-david It's already stored without the hostname, and that should of course remain the same.

The reason I want a full URL here is to be consistent with the REST API in general, where almost everything uses a full URL for serialization. Then it's the client's job to remove the hostname (i.e. with flattenToAppUrl) when the hostname isn't wanted.

We also have sites which use the "preview image link" behavior from plone.volto, where the scale might actually come from a different content item. This is easier to handle on the client side if the serialized image scales have full URLs, so that the client doesn't need to find the right base path.