-
-
Notifications
You must be signed in to change notification settings - Fork 194
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
PLIP: Retina image scales #1483
Comments
That's interesting.
Don't you think we could use the HTML5
?
Note: that's exactly the same problem @Gagaro is facing in this PR: plone/plone.namedfile#21 (which aims to use SVG in images, for a quite similar purpose as yours, considering SVG scale automatically). |
In fact images will be almost 4 times bigger. You could bring jpeg quality down however (assuming it is a jpeg) at these scales without really taking a hit in terms of how the image looks, so that images won't really be that much bigger.
Indeed, this is better. No support in IE, but fewer high res screens on devices running IE, so I don't think that's a deal breaker. @ebrehault Thanks for the input. |
yes, I prefer @ebrehault solution: HTML5 take a look at collective.lazysizes and the lazysizes library to see how responsiveness works with that. supporting HTML5 big +1 on this PLIP. |
@didrix Welcome! Your Plone Contributors Agreement has been processed. Thank you very much for your contributions. |
+1 for srcset. |
in fact there are two options: picturefill and respimg; lazysizes is not a polyfill. |
I have tried to find ways to do this in combination with hveralrde's collective.lazysizes. Maybe it could be possible to 'not hardcode' which values to return In other words: if someone adds a scale with name 'something 100x100', a scale 'something2x 200x200' is also created, but this does not show up in TinyMCE etc. I put up a demo site here: |
The PLIP has been approved. See https://community.plone.org/t/framework-team-meeting-minutes-2016-04-12/1943 |
The overall idea is fine, the implementation details are for discussion. We provide content image tags by
Given we want to use generated image tags all over the place, we have a central infrastructure to do so. With modern browsers we can use So our image tags are generated (currently using very basic string concatenation) we can simply build something to say in a template using a (hypothetic)
and get out of it something like:
or even generate The basic two ideas behind this are:
Other (out of scope here, but in future) ideas: Let the image tag generator support SVG and inline it this way. The tag needed for this to show a svg could then be generated easily. |
What I found very interesting is this example from SelfHTML:
This provides responsive images AND retina image scales for each of them. |
@thet sure, this is possible. But i think this would enhance the scope of this PLIP a lot. I'd like first implement So I'd say: first retina, then look further, otherwise this one gets too complex. |
Thanks for the comments, interesting. It is tempting to create such a thing though. For one thing, it makes it easier to notice if a template is still using an old way of showing images. And if needed, this one It might be that |
In fact we have this one-for-all with the |
Well, that is just |
well, for the default tag of a scale it is sufficient, if title, alt, or something else need to be passed, then it's clumsy :) |
Sure, but then you would just need to use this:
With an
It does not seem to matter, except that with an |
You're right, our current one is not that bad. Overall it is an implementation detail and does not matter so much. |
And regarding TinyMCE, I guess we have 2 solutions:
|
regarding TinyMCE (and overall in theory beyond) it could also be an option to use transformchain to replace specific image tags, i.e. marked with a specific class or a data attribute with an other tag. I am just not sure if this is too in-transparent. |
Using transformchain would imply to ask the server to render+reload the currently edited TinyMCE content everytime an image id added/modified. Sounds more difficult. |
For a first (crude) try I made some adaptations in plone.namedfile.scaling. The tag() function now generates a srcset attribute with the links to the appropriately scaled images. This seemed like the simplest solution and it seems the work quite well. Todo
ProblemsHere are some hurdles I have found: Waking objectsThere is the problem of having to wake objects in order to generate tags from them. For instance in the news portlet images (plone.app.portlets) the image src's are generated using TinyMCETiny always scales the image as scale=large irrespective of how the user scales the image by dragging the corners. Dragging the corners only affect the width and height attributes of the img tag and not the image itself. |
@didrix, it sounds as a good start! |
awesome! I would leave optimizations to the end: it would be nice to compare computing time on before and after. |
Plip config is at https://github.com/plone/buildout.coredev/blob/5.1/plips/plip-1483-retina-image-scales.cfg @didrix Note this recently merged pull request that may influence your work: plone/plone.namedfile#24 |
@didrix @mauritsvanrees is a PLIP jenkins job needed? |
@gforcada Yes, that would be good. |
ops, need to read more careful the console output, now its on GitHub |
@mauritsvanrees I just updated my review with a code-review section about adapterization of Second thing, re-reading this thread, I found that you already mentioned an |
As for testing in the wild: you can see the |
merged! |
Thanks for the great work! |
Phantastic / I am merging with PLIP #1734 right now. I found still some locations to upgrade:
furthermore
How should this work with TinyMce ... ? |
Thanks for the reviews and the merge. So, reading the reviews and final comments, it seems there may be room for some extra fixes or ideas:
|
…press thumbs, thumb size, suppress icons) https://plone/Products.CMFPlone#1734 applied retina_PLIP (plone/Products.CMFPlone#1483)
sorry I uploaded too small images, works fine!"
|
…press thumbs, thumb size, suppress icons) https://plone/Products.CMFPlone#1734 applied retina_PLIP (plone/Products.CMFPlone#1483)
…press thumbs, thumb size, suppress icons) https://plone/Products.CMFPlone#1734 applied retina_PLIP (plone/Products.CMFPlone#1483)
fixed review findings flake8
* Added link for lxml savehtml plip 1343. * Document meta bundles generation plip 1277 in upgrade guide. * Document actions control panel plip 1342 in upgrade guide. * Upgrade guide: use local TOC, and move sections around. * Removed internal links of PLIPs that were already moved. * Document PLIP 1310 in upgrade guide. * Slightly nicer doc for actions control panel. * Added screen shots for actions CP and sharing group link. * Document PLIP 1659 in upgrade guide. * Document PLIP 1340 (QI) in upgrade guide. * Fixed warnings in develop/addons/upgrade_to_51.rst. This prevented the addon_installation_code reference from working. * Document PLIP 1406 (conditional reg) in upgrade guide. * Document PLIP 1484 (conf reg) in upgrade guide. * Changed header underlines. I was using underlines for level 5 (`^^^^`) where they should have been level 4 (`~~~~`). * Document PLIP 1674, auto image rotate, in upgrade guide. * Document PLIP 1343, merge c.indexing, in upgrade guide. * Document PLIP 1441, lxml safehtml, in upgrade guide. * Document PLIP 1600, search order, in upgrade guide. * Upgrade guide: use Capitalized Headings. That is what the style guide says. * Document PLIP 1483, hidpi images, in upgrade guide. * Added HiDPI low/high pictures by Johannes Raggam. Taken from plone/Products.CMFPlone#1483 * Minor fixes in add-ons upgrade doc for icons/thumbs. * Document PLIP 1734, icons/thumbs, in upgrade guide.
Proposer : Diederik Veeze
Seconder : Maurits van Rees
Abstract
Scale images in plone.scale such that they will look good on devices with pixel ratios higher than 1.
Motivation
More and more devices these days can display images with higher resolution than the html/css resolution. Plone however often serves images that are scaled to the exact same size as html/css resolution, while a lot of devices can display twice the resolution.
Assumptions
N/A
Proposal & Implementation
I propose to add an option to the imaging control panel to set a pixel ratio for image scaling. Images generated in plone.scale will generate images whose height and width are multiplied by this pixel ratio. For instance an image in the site of 320x240 with a scaling factor of 2 should result in something like the following:
<img src="someimage-640x480.jpeg" alt="Some Image" width="320" height="240">
Deliverables
Risks
The image scales will get larger, but the image quality for these larger scales can be reduced while still giving a satisfactory result, for only a small increase in byte size.
Participants
@mauritsvanrees
Note
I recently signed the contributor assignment agreement and am awaiting confirmation.The text was updated successfully, but these errors were encountered: