-
-
Notifications
You must be signed in to change notification settings - Fork 3.7k
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Responsive images support #5027
Comments
cc @fredck |
I think that the image feature must somehow consider that. Perhaps it's enough that this is an anticipated and possible extension. Because I don't see how an end-user could specify various sizes through the image dialog. |
Exactly. By default, we must take in consideration that the user will have access to one single image size. We may leave it open to have an API that allows for several different sizes. In the other hand, responsiveness is not about image size, which instead is related to bandwidth optimization. Responsiveness is actually about having the image adapting to different situations. Therefore, if we're able to produce responsive markup (+ CSS) that makes such images responsive, then it would be great. The CSS thing is the tricky part. The CSS must be in the page delivering the content. It's not a CKEditor feature. In any case, alignment features must be CSS driven as well, so I would not be too worried about it, other than providing a good template in the documentation. |
Responsive images are using basically two attributes srcset attributeThe Containing pixel density descriptor
This allows to define different image sizes for screens with different density. This is a good solution when image has a fixed width on the page. Containing width descriptor
This allows to define different image sizes and let the browser choose which image should be loaded - this is strictly connected with sizes attributeThe
This are some tips to the browser about the page layout, helping to decide which image should be loaded. In above example:
Problem (tldr)Image responsiveness is clearly connected with its final presentation. We need to know the context: page layout and how the content will be presented there, to properly decide which approach to take and how to eventually generate |
If there is nothing more we can do, we should take the viewport width. This way we will prevent loading images wider than the viewport width. It's not a perfect solution, but still better than loading always a full-width image. |
To rephrase a bit the problem – if we set the From that perspective, Doooh. |
The problem is that we don't know what is the ratio: width of the editor/width of the image. I think that to be safe we should assume that it can be 100%. |
Or we can make a config option: |
A config option may be a go. As ridiculous as it sounds, it seems that this information just has to be hardcoded with the data, so an option to configure this may be the only optimal option. |
This, ofc, means that the content will be less portable and will be dependent on the current layout of the target webpage. Aaaaaa 😨 😨 😨 😨 😨 😨 😨 😨 So, for some small set of cases a config option may be a solution – it'd allow adjusting the content to the current shape of the website. But it means that if the website's layout is changed, someone may need to reprocess the content in the database. Therefore, our approach could be different – the default behaviour of the editor would be to output inoptimal but safe |
Another doubt from f2f talk with Reinmar is what to do with pasted images. They can have different setup of |
For pasted images, we take the biggest available image and upload it, ignoring the rest. The uploading service will then return the proper list of sizes. |
We can't remove these attributes from all pasted images, because some of these images might've been created in the same editor. We don't have the support yet differentiation between external/internal content yet, so we can't quickly implement it. But in general, PS. I wonder if browsers put |
.... and yes, forget about |
Actually, this is true about |
I don't think you're right. |
I don't think we can do it.
I also thought it works this way. Instead, the browser needs to decide which size should be taken before the styles are loaded. The browser needs As I said before I think that to be safe we should assume that it can be not wider than 100% viewport width since we don't what percent of the viewport width image takes. I think that clipboard is a separate issue. |
That's the point... "100vw" is the assumed default for |
It is the assumed value but it needs to be specified anyway:
Plus:
|
I guess we can keep |
👍 I wanted to propose the same. It's ok for now. Later, we may think what to do if someone loaded into the editor a different |
Sounds like an interesting idea. Hardcoding anything which at some point will become invalid may sound stupid, but you can always write a script to update your image tags in your database.
Looks like the way to go as well, it can be a "recommended practice" and an OOTB solution which we could provide e.g. in Drupal. Suppose that some day we provide a module Drupal that allows for inserting responsive images. What we could do there is introducing an easy to understand "runtime" configuration option that can be set at any moment. The value of this config option would adjust "on the fly" the sizes attribute inside rendered |
Loved this idea ;) |
I also agree that it should be not optimized At the same time, I don't think that making
Note that these may be the config option of the upload adapter, not the image feature. |
While I agree that the config option is not needed now as anyone can process the content and fix the value when rendering the website, let's not forget about simple integration cases and simple websites where it's really just a lot easier to configure the editor than to introduce some HTML processor on page render. Of course, one could also do a simple |
Yea, I was also thinking about some this kind of the placeholder.
Well, not exactly. We can not promise that it will be always |
KISS in the beginning, please... no configurations and |
Feature: Introduced support for responsive image's `srcset` attribute. Closes #2.
am getting this how can i solve this |
Should image feature be responsible for supporting responsive images? Should this be an editor responsibility?
The text was updated successfully, but these errors were encountered: