Skip to content
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

Add image srcset definition and json schema #5

Merged
merged 35 commits into from
Jun 16, 2022

Conversation

MrTango
Copy link
Contributor

@MrTango MrTango commented Apr 8, 2022

needs an upgrade step in plone.app.upgrades to load the config

@MrTango MrTango force-pushed the mrtango-image-handling-sourcesets-settings branch from 91724ae to 8dcbd0f Compare April 8, 2022 16:45
@MrTango MrTango force-pushed the mrtango-image-handling-sourcesets-settings branch from 8dcbd0f to 2799df3 Compare April 19, 2022 14:28
@tisto
Copy link
Member

tisto commented Apr 21, 2022

Just for the record. We are adding a new srcset configuration option for Classic here and it totally unclear how this would relate to the srcset handling and configuration of Volto. If we continue to move in that direction, we risk that we will end up with two srcset configurations in the Plone control panel (one for Classic and one for Volto).

If we continue to treat control panels in Plone 6 as "Classic only" and ignore Volto in the picture I honestly don't see how we could keep both together in the long run.

We plan to address the handling of control panels in Volto in general during Beethoven Sprint in the first week of May. Adding new options does not make our job easier, especially not if they are conflicting with settings that we plan to have in Volto as well.

I don't want to hold back the development of Classic here and srcsets are for sure a useful feature. Though, if we don't find a solution for these kinds of problems, my fear is that we will end up with a fork of Volto and Classic at some point.

The bottom line is this: if our plan is to continue to add new features to Plone Classic and we don't have the time or energy to sync our efforts, we should say this clearly right away and then live (and plan) with the consequences.

It is essential IMHO that the Plone community understands that the @plone/volto-team is always on the "weak end" of things here. We rely on Plone Core/Base/Classic and we need to take any change into account and make sure things work and do not affect Volto in a negative way.

If we treat Plone 6 (Volto) as a product, we must not ship a control panel setting that has no effect whatsoever (I am aware that we already have lots of those anyways and that we need a solution to this in general).

@plone/framework-team I'd like to put this on the agenda for our next meeting.

@jensens
Copy link
Member

jensens commented Apr 21, 2022

It might be a good idea to tackle this at the connected Bonn/Bukarest sprint?

@sneridagh
Copy link
Member

My 5c:

@nzambello worked his ass off in:
plone/volto#2103

This PR is still not merged, but it would be amazing if we syncronize the efforts and do not come up with different implementations/solutions. Also, I do not see why it's needed so many "config" in the panel... (in fact, a full control panel at all). Nicola didn't need that much, I think he's only working with the current scales and calculating CSS from that.

Also, if we rely on integrators to come up with the right CSS for each available scale, instead of guiding them, the most probable thing that will happen is that any won't work at the end.

We will hopefully finish the PR during the upcoming Beethoven sprint.

@giuliaghisini
Copy link

Completely agree with @sneridagh.
There's that implementation of srcset from @nzambello that we have been using in our Redturtle's site for a while now...
It doesn't need particular configuration, only a definition of sizes in config.settings, but i think it could be improved reading that data from plone images controlpanel...

@@ -57,13 +60,55 @@ def dump_json_to_text(obj):
Disallow: /*view$
"""

IMAGE_SRCSET_SCHEMA = json.dumps(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This isn't exactly the most beautiful thing to see...

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why? B/c it is on import time?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need this variable at all?
This is just a string, why not having it the image_srcsets field?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it would look ugly in the field definition because there is so much indentation. Calling black on it could even make it worse due to the line length. And we then have two big dictionaries within the field.

default={
"large": {
"title": "Large",
"preview": "++theme++barceloneta/static/preview-image-large.png",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This mentions barceloneta, I am not really sure we want to have it in plone.base

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well. difficult. I think we can go with it, but it is a bit ugly to forward reference defaults.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thinking further, maybe it would be better to not have any complex defaults in here and configure them in the XML in Products.CMFPlone?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that it would be better to have this setup by barceloneta/volto generic setup.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

so far it's mor of an example, we can leave this property out of core anyway.
This is meant to have a preview in the UI.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe it is time for a site profile package in the core? So for classic we could have this and for volto there can be others? Usually it is done out of core for site installations but here we will have different setups. Worth it?

@jensens
Copy link
Member

jensens commented Apr 22, 2022

Also, I do not see why it's needed so many "config" in the panel... (in fact, a full control panel at all). Nicola didn't need that much, I think he's only working with the current scales and calculating CSS from that.

I think we need this. CSS is not enough to deliver different different images for different resolutions. You for sure can strip this down, but its not how modern web works. In our recent project I worked together with a young webdev who wondered why Plone is so limited when it comes to modern srcset and scaling, even why no webp is available. Here we are on multiple levels in the past and need to improve. I talked with @MrTango and others about this and he really looked into the current state of image delivery.

So: CSS is possible, but not enough. Really.

@mauritsvanrees
Copy link
Member

From the looks of it, the PR from Nicola creates tags like this when you request an image for scale 'large':

<img src="foo/@@images/image/large"
  srcset="foo/@@images/image/listing 16w, foo/@@images/image/icon 32w, ... etc." />

So you get the requested scale, plus in the srcset you get url and width of all available scales.
That seems useful, and we could do this in plone.namedfile as well, perhaps as fallback for when the new setting in the control panel is not filled in.
(You don't get the cacheable uniques image urls this way, but maybe that is solved somewhere else already. Anyway, detail.)

It does not look like this would be in any way affected by the new control panel setting. Nor does this seem to need an extra setting of its own. So I think the Volto team should be fine with this. I hope so. I can certainly misinterpret things, I did not fully read the Volto PR.

If an imaging control panel in Volto reads and shows the IImagingSchema, then it should probably hide the new setting, because Volto does not use that. That might be the only extra work. I expect that there are lots of settings in Plone control panels that have no meaning for Volto, also in earlier Plone versions.

@yurj
Copy link

yurj commented Apr 22, 2022

I remember when Plone was full of portal_skin folders and features were in the scripts/templates. More than classic/volto thing, this is a client/server. The srcset feature is server side or client side feature or 50/50? Settings are in the ZODB/zcml or in config files/command line parameters?

@tisto
Copy link
Member

tisto commented Apr 25, 2022

Let's take @jensens recommendation and discuss this during Beethoven Sprint. Most folks involved in the discussion will be there. I guess this will be hybrid discussion/meeting anyways, so anyone who is interested can join us. I will post updates here.

@mauritsvanrees mauritsvanrees merged commit a5243b8 into main Jun 16, 2022
@mauritsvanrees mauritsvanrees deleted the mrtango-image-handling-sourcesets-settings branch June 16, 2022 16:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

9 participants