| #467 | ckeditor5.png | 288.77 KB | jannakha |
| #467 | config.png | 235.48 KB | jannakha |
| #466 | 2061377-466-10.3.x.diff | 67.92 KB | gcalex5 |
| #462 | 2061377-462-9.5.x.patch | 69.58 KB | rishi.kulshreshtha |
| #461 | 2061377-461-9.5.x.patch | 19.71 KB | rishi.kulshreshtha |
| #455 | 2061377-d10.2-455.diff | 67.77 KB | claudiu.cristea |
| #452 | interdiff_449-452.txt | 4.66 KB | vsujeetkumar |
| #452 | 2061377-452.patch | 21.97 KB | vsujeetkumar |
| #449 | 2061377-allow_image_style_selected_dialog-448.patch | 19.19 KB | cobadger |
| #442 | 2061377-442.patch | 67.69 KB | i-trokhanenko |
| #441 | 2061377-441.patch | 66.87 KB | alorenc |
| #438 | 2061377-nr-bot.txt | 152 bytes | needs-review-queue-bot |
| #437 | drupal-2061377-437.patch | 66.78 KB | prudloff |
| #435 | interdiff_434-435.txt | 2.5 KB | nitin shrivastava |
| #435 | 2061377-435.patch | 69.66 KB | nitin shrivastava |
| #434 | 2061377-434-9.5.x.patch | 69.65 KB | twod |
| #428 | 2061377-428.patch | 69.75 KB | jcnventura |
| #428 | interdiff_427_428.txt | 1.54 KB | jcnventura |
| #427 | 2061377-427.patch | 69.74 KB | jcnventura |
| #427 | interdiff_426_427.txt | 2.34 KB | jcnventura |
| #426 | 2061377-426.patch | 69.6 KB | jcnventura |
| #426 | interdiff_420_426.txt | 440 bytes | jcnventura |
| #425 | 2061377-425.patch | 69.17 KB | jcnventura |
| #420 | reroll_diff_410_420.txt | 5.84 KB | timohuisman |
| #420 | 2061377-420.patch | 69.78 KB | timohuisman |
| #418 | interdiff_417-418.txt | 1.87 KB | ravi.shankar |
| #418 | 2061377-418.patch | 69.87 KB | ravi.shankar |
| #417 | 2061377-filter-image-style-417.patch | 69.79 KB | lazysoundsystem |
| #410 | 2061377-image-style-plain.patch | 69.64 KB | clayfreeman |
| #410 | 2061377-image-style-full-do-not-test.patch | 119.92 KB | clayfreeman |
| #407 | interdiff_2061377_403-407.txt | 626 bytes | karishmaamin |
| #407 | 2061377-407.patch | 45.15 KB | karishmaamin |
| #404 | 2061377-403.patch | 45.24 KB | niko- |
| #403 | 2061377-402.patch | 45.49 KB | niko- |
| #399 | Screenshot 2021-01-04 at 13.16.19.png | 107 KB | alexpott |
| #399 | Screenshot 2021-01-04 at 12.56.27.png | 44.61 KB | alexpott |
| #397 | 2061377-397-unofficial-8.9.x.patch | 72.33 KB | claudiu.cristea |
| #397 | 2061377-397-unofficial-8.9.x.interdiff.txt | 3.61 KB | claudiu.cristea |
| #395 | 2061377-395-unofficial-8.9.x.patch | 69.95 KB | claudiu.cristea |
| #393 | 2061377-392-unofficial-8.9.x.patch | 69.53 KB | claudiu.cristea |
| #386 | interdiff_381-386.txt | 574 bytes | vsujeetkumar |
| #386 | 2061377_386.patch | 50.04 KB | vsujeetkumar |
| #381 | interdiff.2061377.379-381.txt | 1.17 KB | longwave |
| #381 | 2061377-381.patch | 50.2 KB | longwave |
| #379 | interdiff_377-379.txt | 2.18 KB | ravi.shankar |
| #379 | 2061377-379.patch | 50.29 KB | ravi.shankar |
| #377 | interdiff.2061377.371-377.txt | 3.88 KB | longwave |
| #377 | 2061377-377.patch | 50.24 KB | longwave |
| #371 | 2061377-371.patch | 50.15 KB | gaëlg |
| #370 | 2061377-370-interdiff.txt | 2.81 KB | gaëlg |
| #370 | 2061377-370.patch | 51.5 KB | gaëlg |
| #362 | 2061377-362.patch | 51.05 KB | claudiu.cristea |
| #362 | 2061377-362.interdiff.txt | 6.27 KB | claudiu.cristea |
| #359 | 2061377-358.patch | 51.11 KB | claudiu.cristea |
| #359 | 2061377-358.interdiff.txt | 1.75 KB | claudiu.cristea |
| #356 | 2061377-356.patch | 51.15 KB | claudiu.cristea |
| #356 | 2061377-356.interdiff.txt | 20.87 KB | claudiu.cristea |
| #354 | 2061377-354-8.8.x.patch | 48.62 KB | claudiu.cristea |
| #349 | interdiff.txt | 1.8 KB | rensingh99 |
| #349 | 2061377-349-8.9.x.patch | 48.43 KB | rensingh99 |
| #345 | 2061377-345-8.8.x.patch | 48.29 KB | joegraduate |
| #345 | interdiff_338-345.txt | 740 bytes | joegraduate |
| #338 | 2061377-338-8.7.x.patch | 48.32 KB | jcnventura |
| #338 | interdiff.txt | 931 bytes | jcnventura |
| #334 | 2061377-334-8.7.x.patch | 48.34 KB | claudiu.cristea |
| #328 | interdiff_326-328.txt | 3.37 KB | heddn |
| #328 | 2061377-328.patch | 48.28 KB | heddn |
| #326 | interdiff_324-326.txt | 2.42 KB | heddn |
| #326 | 2061377-326.patch | 47.6 KB | heddn |
| #324 | interdiff_321-324.txt | 794 bytes | heddn |
| #324 | 2061377-324.patch | 47.22 KB | heddn |
| #321 | 2061377-321.patch | 47.16 KB | heddn |
| #319 | 2684689-319.patch | 48.65 KB | heddn |
| #318 | interdiff_316-318.txt | 1.5 KB | heddn |
| #318 | 2684689-318.patch | 88.24 KB | heddn |
| #316 | interdiff_314-316.txt | 10.32 KB | heddn |
| #316 | 2061377-316.patch | 48.71 KB | heddn |
| #314 | 2061377-314.patch | 49.09 KB | heddn |
| #314 | interdiff_309-314.txt | 11.91 KB | heddn |
| #309 | 2061377-309.interdiff.txt | 1.42 KB | claudiu.cristea |
| #309 | 2061377-309.patch | 48.62 KB | claudiu.cristea |
| #308 | 2061377-308.patch | 48.7 KB | claudiu.cristea |
| #308 | 2061377-308.interdiff.txt | 1.27 KB | claudiu.cristea |
| #307 | 2061377-307.interdiff.txt | 2.3 KB | claudiu.cristea |
| #307 | 2061377-307.patch | 48.56 KB | claudiu.cristea |
| #305 | 2061377-305.interdiff.txt | 12.26 KB | claudiu.cristea |
| #305 | 2061377-305.patch | 47.66 KB | claudiu.cristea |
| #303 | 2061377-303.interdiff.txt | 11.34 KB | claudiu.cristea |
| #303 | 2061377-303.patch | 43.58 KB | claudiu.cristea |
| #301 | 2061377-301.patch | 44.32 KB | claudiu.cristea |
| #293 | 2061377-293-8.4.x-version-of-291.patch | 44.16 KB | claudiu.cristea |
| #292 | 2061377-291-8.4.x.patch | 14.4 KB | claudiu.cristea |
| #291 | 2061377-291.interdiff-to-282.txt | 762 bytes | claudiu.cristea |
| #291 | 2061377-291.patch | 44.2 KB | claudiu.cristea |
| #289 | 2061377-289-interdiff.txt | 816 bytes | sandervd |
| #289 | 2061377-289.patch | 11.1 KB | sandervd |
| #286 | filter-settings-after.png | 42.12 KB | anthony.bouch |
| #286 | filter-settings-before.png | 70.31 KB | anthony.bouch |
| #285 | uObSlEYpvt.mp4 | 1.66 MB | mahalingam_cs |
| #228 | allow_image_style_to_be-2061377-228.patch | 30.62 KB | ada hernandez |
| #228 | interdiff-224-228.txt | 2.33 KB | ada hernandez |
| #224 | interdiff_221-224.txt | 15.07 KB | heddn |
| #224 | allow_image_style_to_be-2061377-224.patch | 30.62 KB | heddn |
| #221 | interiff_218-221.txt | 2.39 KB | heddn |
| #221 | allow_image_style-2061377-221.patch | 33.46 KB | heddn |
| #218 | interdiff_216-218.txt | 1.55 KB | heddn |
| #218 | allow_image_style-2061377-218.patch | 36.42 KB | heddn |
| #216 | allow_image_style-2061377-216.patch | 36.53 KB | heddn |
| #216 | interdiff_211-216.txt | 985 bytes | heddn |
| #211 | allow_image-2061377-211.patch | 36.3 KB | heddn |
| #211 | interdiff_209-211.txt | 3.61 KB | heddn |
| #209 | interdiff_206-209.txt | 69.13 KB | heddn |
| #209 | allow_image-2061377-209.patch | 35.83 KB | heddn |
| #206 | interdiff_204-206.txt | 1.85 KB | juancasantito |
| #206 | allow_image-2061377-206.patch | 102.61 KB | juancasantito |
| #204 | allow_image-2061377-204.patch | 102.63 KB | juancasantito |
| #198 | interdiff-2061377-183-198.txt | 7.3 KB | rainbowarray |
| #198 | 2061377-198-wysiwyg-image-styles.patch | 108.17 KB | rainbowarray |
| #183 | interdiff-2061377-182-183.txt | 3.68 KB | rainbowarray |
| #183 | 2061377-183-wysiwyg-image-styles.patch | 108.12 KB | rainbowarray |
| #182 | interdiff-2061377-181-182.txt | 16.81 KB | rainbowarray |
| #182 | 2061377-182-wysiwyg-image-styles.patch | 108.44 KB | rainbowarray |
| #181 | interdiff-2061377-174-181.txt | 58.46 KB | rainbowarray |
| #181 | 2061377-181-wysiwyg-image-styles.patch | 108.48 KB | rainbowarray |
| #175 | Screen Shot 2016-05-20 at 15.24.13.png | 20.05 KB | wim leers |
| #175 | Screen Shot 2016-05-20 at 14.53.18.png | 174.95 KB | wim leers |
| #174 | interdiff-2061377-173-174.txt | 15.15 KB | rainbowarray |
| #174 | 2061377-174-wysiwyg-image-styles.patch | 71.99 KB | rainbowarray |
| #173 | interdiff-2061377-172-173.txt | 11.34 KB | rainbowarray |
| #173 | 2061377-173-wysiwyg-image-styles.patch | 65.35 KB | rainbowarray |
| #172 | interdiff-2061377-171-172.txt | 8.53 KB | rainbowarray |
| #172 | 2061377-172-wysiwyg-image-styles.patch | 59.35 KB | rainbowarray |
| #171 | interdiff-2061377-170-171.txt | 15.29 KB | rainbowarray |
| #171 | 2061377-171-wysiwyg-image-styles.patch | 55.09 KB | rainbowarray |
| #170 | interdiff-2061377-168-170.txt | 7.94 KB | rainbowarray |
| #170 | 2061377-170-wysiwyg-image-styles.patch | 49.98 KB | rainbowarray |
| #168 | interdiff-2061377-166-168.txt | 3.86 KB | rainbowarray |
| #168 | 2061377-168-wysiwyg-image-styles.patch | 50.71 KB | rainbowarray |
| #167 | interdiff-2061377-165-166.txt | 8.85 KB | rainbowarray |
| #167 | 2061377-166-wysiwyg-image-styles.patch | 50.2 KB | rainbowarray |
| #165 | interdiff-2061377-161-165.txt | 9.45 KB | rainbowarray |
| #165 | 2061377-165-wysiwyg-image-styles.patch | 47.4 KB | rainbowarray |
| #164 | interdiff-2061377-159-161.txt | 17.3 KB | rainbowarray |
| #163 | interdiff-2061377-154-159.txt | 1.95 KB | rainbowarray |
| #163 | 2061377-161-wysiwyg-image-styles.patch | 49.34 KB | rainbowarray |
| #160 | interdiff-2061377-154-159.txt | 1.95 KB | rainbowarray |
| #159 | interdiff-2061377-154-159.txt | 508.04 KB | rainbowarray |
| #159 | 2061377-159-wysiwyg-image-styles.patch | 41.57 KB | rainbowarray |
| #155 | interdiff-2061377-151-154.txt | 4.25 KB | rainbowarray |
| #155 | 2061377-154-wysiwyg-image-styles.patch | 41.82 KB | rainbowarray |
| #152 | 2061377-151-reroll-wysiwyg-image-styles.patch | 39.45 KB | rainbowarray |
| #144 | wysiwyg-image-styles-2061377-144.patch | 48.84 KB | mitchalbert |
| #142 | wysiwyg-image-styles-2061377-142.patch | 23.51 KB | mitchalbert |
| #139 | wysiwyg-image-styles-2061377-139.patch | 20.45 KB | mitchalbert |
| #124 | interdiff-2061377-110-124.txt | 765 bytes | rainbowarray |
| #124 | 2061377-124-wysiwyg-image-styles.patch | 44.27 KB | rainbowarray |
| #110 | interdiff-109-110.txt | 1.71 KB | jelle_s |
| #110 | 2061377-110-wysiwyg-image-styles.patch | 44.26 KB | jelle_s |
| #109 | interdiff-108-109.txt | 16.74 KB | jelle_s |
| #109 | 2061377-109-wysiwyg-image-styles.patch | 43.59 KB | jelle_s |
| #108 | interdiff-98-107.txt | 3.65 KB | jelle_s |
| #108 | 2061377-107-wysiwyg-image-styles.patch | 43.69 KB | jelle_s |
| #98 | interdiff-87-98.txt | 19.14 KB | jelle_s |
| #98 | 2061377-98-wysiwyg-image-styles.patch | 40.04 KB | jelle_s |
| #87 | 2061377-87-wysiwyg-image-styles.patch | 23.9 KB | jelle_s |
| #81 | 2061377-79-wysiwyg-image-styles.patch | 26.64 KB | rainbowarray |
| #80 | interdiff-2061377-73-79.txt | 650 bytes | rainbowarray |
| #78 | allow_image-2061377-73-reroll.patch | 27.27 KB | rainbowarray |
| #73 | allow_image-2061377-73.patch | 27.13 KB | garphy |
| #69 | allow_image-2061377-69.patch | 27.67 KB | dimaro |
| #69 | interdiff-2061377-60-69.txt | 10.41 KB | dimaro |
| #60 | interdiff.txt | 10.43 KB | erik.erskine |
| #60 | 2061377.60.patch | 27.53 KB | erik.erskine |
| #56 | interdiff.txt | 1.05 KB | jelle_s |
| #56 | 2061377.56.patch | 27.05 KB | jelle_s |
| #53 | 2061377.53.patch | 27.05 KB | jelle_s |
| #42 | 2061377.42.patch | 27.72 KB | tonnosf |
| #41 | 2061377.41.patch | 17.07 KB | tonnosf |
| #36 | 2061377.36.patch | 40.63 KB | miraj9093 |
| #10 | responsive_inline_images-2061377-10.patch | 36.31 KB | wim leers |
| #10 | interdiff.txt | 2.2 KB | wim leers |
| #8 | editor_image_dialog-picturemapping.png | 64.02 KB | wim leers |
| #8 | editor_image_dialog-picturemapping-preview.png | 110.39 KB | wim leers |
| #8 | editor_image_dialog-picturemapping-editor.png | 60.77 KB | wim leers |
| #8 | editor_image_dialog-imagestyle.png | 73.13 KB | wim leers |
| #8 | editor_image_dialog-imagestyle-preview.png | 136.74 KB | wim leers |
| #8 | editor_image_dialog-imagestyle-editor.png | 77.4 KB | wim leers |
| #8 | picturemapping-demo-LQ.mp4_.zip | 2.09 MB | wim leers |
| #8 | imagestyle-demo-LQ.mp4_.zip | 1.4 MB | wim leers |
| #8 | responsive_inline_images-2061377-8.patch | 36.21 KB | wim leers |
| #232 | interdiff-2061377-228-232.txt | 25.29 KB | ifreeman |
| #232 | 2061377-232.patch | 35.28 KB | ifreeman |
| #237 | 2061377-237.patch | 34.83 KB | ifreeman |
| #237 | interdiff-2061377-232-237.txt | 8.98 KB | ifreeman |
| #239 | 2061377-239.patch | 34.91 KB | naveenvalecha |
| #239 | interdiff-2061377-237-239.txt | 1.91 KB | naveenvalecha |
| #241 | 2061377-241.patch | 37.23 KB | naveenvalecha |
| #241 | interdiff-2061377-237-241.txt | 4.17 KB | naveenvalecha |
| #241 | interdiff-2061377-239-241.txt | 3.44 KB | naveenvalecha |
| #246 | 2061377-246.patch | 38.29 KB | kingdutch |
| #246 | interdiff-2061377-241-246.txt | 1.12 KB | kingdutch |
| #250 | 2061377-250.patch | 38.4 KB | pfrenssen |
| #254 | 2061377-254-tests_only.patch | 16.51 KB | pfrenssen |
| #254 | 2061377-254.patch | 39.01 KB | pfrenssen |
| #254 | interdiff.txt | 12.42 KB | pfrenssen |
| #256 | 2061377-256-tests-only.patch | 16.51 KB | pfrenssen |
| #256 | 2061377-256.patch | 41.99 KB | pfrenssen |
| #256 | interdiff.txt | 6.85 KB | pfrenssen |
| #262 | 2061377-261-tests_only.patch | 16.51 KB | pfrenssen |
| #262 | 2061377-261.patch | 42.03 KB | pfrenssen |
| #262 | interdiff.txt | 1.45 KB | pfrenssen |
| #265 | 2061377-264.patch | 43.46 KB | pfrenssen |
| #265 | 2061377-264-tests_only.patch | 16.46 KB | pfrenssen |
| #265 | interdiff.txt | 5.45 KB | pfrenssen |
| #267 | image-style-dependency.png | 121.53 KB | pfrenssen |
| #267 | 2061377-267-tests_only.patch | 15.96 KB | pfrenssen |
| #267 | 2061377-267.patch | 43.21 KB | pfrenssen |
| #267 | interdiff.txt | 8.18 KB | pfrenssen |
| #270 | 2061377-270-tests_only.patch | 15.96 KB | pfrenssen |
| #270 | 2061377-270.patch | 43.42 KB | pfrenssen |
| #270 | interdiff.txt | 1.01 KB | pfrenssen |
| #273 | 2061377-273-tests_only.patch | 15.95 KB | pfrenssen |
| #273 | 2061377-273.patch | 43.5 KB | pfrenssen |
| #273 | interdiff.txt | 2.18 KB | pfrenssen |
| #277 | 2061377-test-273.gif | 1.68 MB | vijaycs85 |
| #282 | interdiff-2061377-273-282.txt | 20.98 KB | ifreeman |
| #282 | allow_image_style_to_be-2061377-282.patch | 43.98 KB | ifreeman |
Comments
Comment #1
wim leerswebchick labeled Drupal 8's inability to have responsive images (i.e. the
<picture>element) in the body field as a bug over at #2099909-13: Images in body field are not responsive. Looks like we might indeed want to have the ability to select picture mappings in the image dialog then!Comment #2
wim leersAlright, confirmed, I'll be working on this in the next two weeks :)
Comment #3
wim leersAdopting the tags of #2099909: Images in body field are not responsive, which was marked as a duplicate in favor of this one.
Comment #4
webchickYeah, what we talked about is that from an end-user point of view, both an image upload field that's attached to a Field API "image" field and an image upload field found inside CKEditor are conceptually the same: an upload field, where you stick an image. It's therefore very perplexing when one has responsive goodness without having to think about it and the other doesn't, and it makes D8 look kinda bad, considering mobile was such a strong focus for us.
Thanks, Wim! :)
Comment #5
attiks commentedIssue for the picture module at #2000178: Add support for inline pictures in short this is possible using an image tag with a data-picture attribute
Comment #6
wim leers#5: Thanks!
Comment #7
wim leersWhile working on this, I encountered an important regression in the
#statesAPI that blocks this patch, see #1589176-14: Follow-up: Use data-* to store #states api informations.Comment #7.0
wim leersUpdated issue summary.
Comment #7.1
wim leersUpdated issue summary.
Comment #7.2
wim leersUpdated issue summary.
Comment #8
wim leersTesting the patch
No setup necessary. Everything enabled out of the box, including a default picture mapping. Just install on simplytest.me, go to
node/add/article, click the "image" button in CKEditor and it's there.Note that if you want the in-dialog preview to work correctly, you need to apply #1589176-14: Follow-up: Use data-* to store #states api informations as well.
(For future note: this patch was rolled on top of 75debc110d4b8bbc2f5afdd60ddfd2c03bbd1c48.)
Patch concept
data-picture-mappingattribute on the<img>, with the assistance of the image dialog in the text editor. It includes a toggleable preview that explains what can be expected to happen.(Nothing about this is CKEditor-specific; the only changes made to CKEditor-related code is to prevent the
DrupalImageCaptionplugin from ignoring and hence stripping attributes it doesn't particularly care about.)filter_picturemappingfilter detect this attribute and, replace the<imgtag with whatever HTMLpicture.modulegenerates.(For those who don't want responsive images, the exact same stuff is implemented for "just" image styles:
data-image-style+filter_imagestyle.)Screenshots! Screencasts!
(Please ignore the extremely crappy video quality when resizing the browser window to show that the image is responsive. Either Chrome or QuickTime Player suck, or both.)
filter_picturemapping: https://dl.dropboxusercontent.com/u/80682862/spark/image%20dialog/pictur... (LQ demo attached for posterity, HQ demo is too big for d.o)filter_imagestyle: https://dl.dropboxusercontent.com/u/80682862/spark/image%20dialog/images... (LQ demo attached for posterity, HQ demo is too big for d.o)Things of note
filter_imagestyle: a "live preview" in the text editor is trivial: just set thesrc,widthandheightattributes to the corresponding values for the selected image style.filter_picturemapping: a "live preview" in the text editor is non-trivial: having an actual<picture>element in CKEditor is theoretically possible, but very, very complex. Not something we want to tackle here. So instead, we just want to show *one* (non-responsive) image, but then the question is: which breakpoint do we choose (which would then be the image style we'd use). For now, I've gone with picking the smallest breakpoint, because that'll work across devices. So, effectively, it works analogously tofilter_imagestyle.picture.module-related code will become cleaner once #2123251: Improve DX of responsive images; convert theme functions to new #type element is fixed :)Further thoughts
Comment #10
wim leersWorks fine here. Different PHP versions. Easy fix.
Testing the patch
No setup necessary. Everything enabled out of the box, including a default picture mapping. Just install on simplytest.me (use the link below), go to
node/add/article, click the "image" button in CKEditor and it's there.simplytest.me link that includes all dependencies
Comment #11
tim.plunkettCan't that just be key($image_options)?
Comment #12
wim leers#11: hah — I did not even know that function existed :D We can trust that PHP will always have the array pointer pointing to the first item? I've never dared to rely on the internal array pointer before.
Comment #13
Bojhan commentedI spend a long time discussing this with WimLeers (I was a little confused, IRC to the rescue!) . Overall its a great idea, Drupal is quite unique if we pull this off.
However it requires a lot of fine tuning of the details.
I was quite confused by "Standard responsive image" as a option. Because that immediately made me think about image styles, instead of picture maps. I expect that users will also face this confusion, and will go to Configuration > Media > Image styles and end-up terribly confused that they don't find "Standard responsive image” in there.
Just an idea. What if we turn the label around and indicate in some way that its different from ordinary image styles?
Responsive image style: “Standard"
Although I am worried that “responsive” might be a odd label for many content authors and possibly outdated in a few years. It is the label we use elsewhere. I think we can safely assume that if you use picture maps that they will be responsive.
If anyone has a better label than “picture mapping” that could work too.
(FYI, in D7 discussions with Nate I offered the idea of using “image styles” instead of “image cache”. It looks like this situation is just the same, we gotta find a good label.)
Comment #14
wim leersI'm totally fine with labeling it "Responsive image style" instead of "Image style" in the image dialog UI. But as you already say: this might be outdated in a few years, and then just look ridiculous. That's why I called it just "Image style" in the image dialog UI. However, that's precisely what confused you.
So, AFAICT, "Responsive image style" is still the best choice.
If all discovered problems are just of labeling things, then I'd be very surprised/happy :P :D
I'll hold off rerolling until more things need to change than just UI strings. Unassigning myself too, because I'd love somebody else who's passionate about this to take the initial patch I provided and continue from there. I'll be working on performance issues for the majority of my time the next two weeks.
Comment #14.0
wim leersUpdated issue summary.
Comment #15
eule commentedpls proof thats the pictures are possible to add in a picture sitemap.
if not we need to open a new issue. thanks
Comment #16
attiks commentedIf you mean the following it isn't supported by any responsive solution, but it's possible to do. I think it's better to open a new issue and link it to this one. You'll probably need to define multiple maps depending on the image to be used.
Comment #17
eule commentedhttps://drupal.org/node/2126287 done ..maybe bad writeup
Comment #18
larowlanis this used? doesn't seem to be.
Half way through review
Comment #19
wim leers#18: You're right. That should be removed. Looking forward to the second half :)
Comment #20
dave reidI'm curious, why not support all the formatters available to image fields rather than just only show image styles? Something like
<div data-image-fid="5" data-image-formatter="image" data-image-formatter-options="{json encoded string of optional formatter options" />Comment #21
David4514 commentedNote that the breakpoints property of a breakpointGroup is now protected. You need to use the getBreakpoints method instead. This effects two lines in the new FilterPictureMapping.php file that this patch installs.
Original code
Suggested changes.
Comment #22
wim leers#20: that'd result in a
<div class="field"><div class="field-item"><img src="http://drupal.org/foobar.jpg" /></div></div>inside a text body. That's… excruciatingly bad.#21: thanks! :)
Comment #23
jelle_s#12: To be sure, you can call
reset($image_options)first (see http://www.php.net/reset)Comment #24
dasjo#20 makes me think about arbitrary embeds of fields and picking a view mode / field formatter :)
Comment #25
yched commented@Dave Reid / @Wim Leers:
Not necessarily. The above is if you call field_view_field() : "html for a fully themed field, with wrappers, rdf, label & multiple values".
But you can still let a single formatter run with field_view_value() : single value, no decoration, pure formatter output
Comment #26
yched commented(side note: field_view_field() / field_view_values() are still old-style functions, and their signatures are still largely modeled after the D7 entity model. This is being taken care of in #2134887: move field_view_field() / field_view_value() to methods)
Comment #27
wim leers#25: but then you're no longer rendering a field, you're rendering a field item. That complicates things.
Comment #28
yched commented@Wim Leers : I guess you mean
"but then you're no longer rendering a *file* [what the patch does currently], you're rendering a field item" ?
If so, then yes, true, would be a big change. You can't easily turn an arbitrary file into a "file field item" - on which entity, with which field definition ?
Which I guess is the reason why this patch only goes with "rendering direclty through an image style" rather than rendering through a field formatter - there's no field :-)
Comment #29
wim leersNo, that's not what I meant. What I meant was that if you want to use
field_view_value(), then you must pass it an$item, not a$field. Therefor, the user must select a field item, not a field. That complicates the UX.This patch only deals with files, just like the existing "insert image" functionality in Text Editor/CKEditor does, which is totally fine, because each file is a file entity and we embed the file entity's UUID in the markup, so we can map it to a file entity. There's simply no need for a field using that approach.
Comment #30
yched commentedHmm - I think we're saying the same thing ;-)
At any rate, I agree with #29. When I wrote #25, I overlooked the fact that the patch works on files, not on "values in an image field".
Comment #31
wim leersGreat to see that you agree :)
Removing "sprint" tag, because we're not actively working on this. The Spark team is focused on solving beta blockers.
Comment #32
anthony.bouch commentedJust wanted to say thank you so much for working on this! I've been a Media user for a while now (and have been reading the media and asset management discussions with regards to Drupal 8 - https://groups.drupal.org/node/384813), although the main use case we have for smaller sites is exactly the one you've addressed here.
Apologies in advance for my unfamiliarity with the patch submission process in Drupal core - but can you tell me what the status is of this patch? Above it says 'Needs Review' and so I'm assuming it's not yet been accepted to core - and won't yet appear in the Drupal 8 Dev Alpha download correct?
If I'd like to to experiment with this patch, will I need to clone the Drupal 8 git repository, and then download an apply the patch separately?
Thanks again....
Comment #33
nod_No worries, we all started somewhere :) Need review means that it is not yet in core, you're correct. It needs someone to test that the functionality works as expected and that the code is up to core standards. Until it is in the "Fixed" state, it won't be in what you download from the alpha version.
The process is the one you described, you need a git clone of the drupal repository and you need to apply the patch on top of it: https://drupal.org/patch/apply
Comment #34
anthony.bouch commentedThanks for this nod_ - and thanks too for the URL on patching. :-)
Comment #35
rainbowarrayThe current patch no longer applies, and there are a number of suggestions for fixes in comments above since the last patch.
Comment #36
miraj9093 commentedRerolled the patch.
Comment #38
attiks commentedComment #39
mark.labrecqueComment #40
mark.labrecqueComment #41
tonnosf commentedI revised the latest patch "2061377.36.patch".
There's remaining two issues:
- After image upload there's an error in the file core/modules/file/file.js.
- On saving the content with an image it won't save the parameter of the used image-style.
Comment #42
tonnosf commentedAdded missing files to patch.
Comment #45
eule commentedhello, just to inform you about the latest news and whats going on. http://www.matthew-steele.com/responsive-images-picture-srcset/
Comment #46
ja_ca commentedWill be looking at this.
Comment #47
ja_ca commentedComment #48
wim leers#1589176: Follow-up: Use data-* to store #states api informations (a blocker) got committed — updated the IS.
Rerolling this now.
Comment #49
almaudoh commentedStill needs re-roll...
Comment #50
dave reidComment #51
jelle_sIf nobody has started yet, I'll reroll this.
Comment #52
erik.erskine commentedJelle_S - are you at the sprint in Amsterdam? I've just started looking at this issue too, happy to help.
Comment #53
jelle_sYes I am, I'm at the table next to the aegir guys. Red DrupalCon Amsterdam T-shirt and glasses ;-).
Straight reroll, tests will probably still fail since they failed in #42 as well, but let's first get this reroll out of the way.
Comment #54
erik.erskine commentedSorry Jelle, having trouble locating you, as aegir isn't marked on the table plan. Whereabouts are you sitting?
I'm on the media table (ground floor, by the window on the right hand side as you come in the room). And I'm wearing the red amsterdam t-shirt too :)
Comment #56
jelle_sNew patch should fix the failing tests.
Comment #57
almaudoh commentedSorry I don't have dreditor on this computer. However, quick review:
$form_statein thehook_XXX_alter()and thehook_XXX_validate()needs to be updated to currentFormStateInterfaceAPIMore in-depth reviews soon...
Comment #58
almaudoh commentedCNW for #57
Comment #59
jelle_sRe #57:
@Erik is working on it, I told him about the test as well since it shouldn't have passed indeed. I just rerolled an fixed the failing tests.
Since the last patch was pretty old, it seems to require a considerable amount of work since a lot has changed (FormStateInterface, Breakpoints are now plugins, no longer entities, and probably many more)
Comment #60
erik.erskine commentedUpdated #56 to fix the following issues:
Still needs work, but hopefully this helps move things on.
Comment #61
erik.erskine commentedThis turns on the responsive_image module for the standard profile - should that really be in here?
Comment #62
attiks commentedI think we will need it, but maybe this is not the right issue to do it (if so create a new issue so we do not forget). The idea is to ship Drupal 8 with responsive image enabled so site builders will follow best practices.
Comment #63
rainbowarrayAlready an issue for that: #1855412: Enable responsive_image.module by default for standard install profile
Comment #64
jelle_sThis should be removed again as well then, because it won't work unless the responsive_image module is enabled.
Comment #65
jelle_sStumbled upon #2350061: Javascript error when uploading image through the editor image dialog while I was working on this patch.
Comment #66
wim leersGreat progress here, thanks guys!
Comment #68
attiks commentedThis needs a reroll, I unassigned it so somebody else can work on it.
Comment #69
dimaro commentedRerolled.
Hope it works!
Comment #70
rainbowarrayTweaking the title name to reflect the change of the picture module to the responsive image module.
Comment #71
dave reidComment #72
garphyLast patch won't apply anymore.
Comment #73
garphyRerolled and fixed several API changes I spotted. (sorry, no interdiff yet)
Comment #74
rainbowarray#2513604: Create default responsive image styles provides some sensible default responsive image styles. It would be good to work on getting that committed, rather than default responsive image style in the Toolbar module added in the patch above. Once that is in, I think it's worth looking at #1855412: Enable responsive_image.module by default for standard install profile so the Responsive Image module is turned on by default, which would allow those default responsive image styles to work out of the box with the Edit widget.
Comment #75
wim leersI talked to @webchick and @mdrummond about this.
Drupal 8 claims to do All The Right Responsive Things, but without this issue, no inline images are ever responsive. Which is kinda sad.
OTOH, #1855412: Enable responsive_image.module by default for standard install profile is also not done yet, so actually, out of the box, Drupal 8 doesn't do any responsive images things at all.
Given that RC1 is in exactly one week, I don't think it's realistic to get all this done by then. Especially because this would benefit from real-world feedback. I think it'd be better to put this patch in a D8 contrib module during 8.0.0, gather real-world feedback, and move it into core in 8.1.0. Then 8.1.0 can say "responsive images support has now matured, it is now enabled by default, and includes support for inline images also".
It's very unfortunate, but from a release manager POV, I think that's the most responsible thing to do.
Comment #76
dave reidMeanwhile, Entity Embed will be there in contrib and work for all output and field formatters for images. I think that's acceptable for now.
Comment #77
wim leers#76: thanks, that's an excellent additional point!
Comment #78
rainbowarrayHere's a reroll of #73 to get us up to date.
Comment #80
rainbowarrayThis removes the default image style added in this patch. Not necessary anymore since we already have default responsive image styles.
Comment #81
rainbowarrayGlitch due to testbot. Here's the patch.
Comment #83
wim leers8.1 is outdated; for the patch to apply, you need to specify 8.0.
Comment #84
rainbowarrayAh, I was really confused by that. Thanks Wim!
Comment #86
jelle_sThis patch needs a bunch of renames: picture mappings no longer exist, they are now responsive image styles. There's todos in there with a link to a fixed issue (#2123251: Improve DX of responsive images; convert theme functions to new #type element) . I'll have a stab at it.
Comment #87
jelle_sThis patch used a lot of old code that is no longer there. Thankfully the refactoring was quite smooth with #2123251: Improve DX of responsive images; convert theme functions to new #type element fixed. I couldn't get the data-attributes to stick somehow. They are never in the output... The rest of the patch seems to work ok. Dialog has correct contents etc. Maybe some theming issues in the previews, but I'm gonna leave those up to the people that know about how things should look in order to look good ;-). Unassigning for now, maybe I'll revisit this later today.
Oh, and I don't know how testable this code is, with all the JS involved, but it feels like this should have tests. Right now there is no response yet for the patch in #81, but if that comes back green, this definitely needs test because that code should just throw fatal errors I think.
Comment #88
wim leersAwesome, thanks for the reroll, Jelle!
Comment #89
attiks commented#87
Don't we have to whitelist the new data- attributes?
Also don't we need javascript to add them, similar to core/modules/ckeditor/js/plugins/drupalimage/plugin.js
@Wim Leers?
Comment #90
jelle_sYeah that's what I thought as well but I'm not sure about the approach, that's why I posted my progress so far so someone with more knowledge about this could chime in :-D
Comment #91
attiks commented#90 That would be @Wim Leers I guess, I had a quick look, the other data attributes are added during install, but I guess there's a dynamic way as well, so we only have to add them when needed.
Comment #92
wim leersYep, the corresponding filter could add them upon being enabled. I can take that part on once it's the last part remaining.
Comment #93
attiks commented#92 What else is remaining, because now it is a bit hard to test. Or do you have pointers where to look? I had a quick look at the javascript, but both allowedContent and requiredContent are hard-coded, I don't see a way to override these?
Comment #94
attiks commentedLayout of the preview is of, but not sure we even need it?
Comment #95
attiks commentedTalked to Wim on IRC, the short version:
- Dialog save is working
- Newly added PHP is working
- AJAX post back is working
- but
Decided it has to be part of this issue so we have a use case as well, but not for me today
Comment #97
attiks commentedQuick update: we have a working version, if anybody has an idea how this can be tested, please let us know
Comment #98
jelle_sHere's the working patch. Tested on Full HTML format, see #92.
I must say I enjoyed writing this patch, DX has really improved in D8 compared to D7!
Comment #99
attiks commented@Wim Leers I guess we need to add the data- attributes to the allowed filter as well during install?
Comment #100
attiks commented#98
- needs d8 to d8 system update
- needs d8 to d8 responsive image update
- needs to add data-image-style to standard profile config
-
needs to add data-responsive-image-style to hook enableUpdate: Removed the hook enable, since it will get added once the filter gets enabled
Comment #101
wim leers…
…
…
I'm speechless. This is beautiful. This is so much more elegant. It makes so much more sense. There are still some rough edges, but I'm certain we can overcome those. This is already a massive leap forward compared to #3 :)
Awesome work, @attiks & @Jelle_S!
attiks++
Jelle_S++
#98:
:) :) :)
Which specific aspect(s) are you referring to though?
#99: Correct. We need to allow these additional attributes by default in the Standard install profile's text formats.
I didn't know about this! Is this new?
Nice!
Why also update the link plugin? For consistency? Shouldn't we just do that in a separate issue?
Docblock needs some love :)
data-image-style<3
<3
Shouldn't this use code similar to that for
requiredContent?drupalimagestyleLet's use short array notation.
filter_image_styleRight, the original patch predates the
data-editor-file-uuid->data-entity-uuidconversion :)However, you'll also want to add the condition
@data-entity-type="file".Just like
_editor_parse_file_uuids()already does.Also needs love :)
Same remark as above.
Shouldn't this be "responsive image style", for consistency with "image style" above?
Interesting, why/how did you run into a problem that caused this change to be necessary?
If it's unnecessary, let's revert this change.
If it's necessary, this will need test coverage proving that it is necessary.
Let's revert this unnecessary change.
After that is all fixed, the only remaining thing to be done is some additional JS for on the text format/text editor configuration page, so that if you enable either of these filters, that the
filter_htmlfilter is also updated accordingly automatically, so that the required attributes are also whitelisted automatically.Comment #102
attiks commented#101
1. Is from CKEditor, see http://docs.ckeditor.com/#!/api/CKEDITOR.style
2. Thanks
3. Indeed for consistency, is a bit small to put in a separate issue
16. Because the img is indented with 2 spaces in the twig file, if we don't do the trim, the first node is #text
Is this how the image caption / image align is done?
Comment #103
wim leers#102.16: actually, no, the image caption/align filters also don't have this yet! Great point. This was an oversight in #2549077: Allow the "Limit allowed HTML tags" filter to also restrict HTML attributes, and only allow a small whitelist of attributes by default. So I think it's fine to also not do that here for these filters, and do all of them at once in a single patch (align + caption + image style + responsive image style, for automatically whitelisting
data-align,data-caption,data-image-styleanddata-responsive-image-style, respectively).Comment #104
attiks commented#103 Just discovered that after selecting image style and hitting save, they get added
Comment #105
attiks commentedAdding 'rc deadline' tag, will assign to @webchick once the code is ready
Comment #106
jelle_sComment #107
attiks commentedChange record added: https://www.drupal.org/node/2579075
Comment #108
jelle_sPatch with #1001, 2 and 3 fixed. 4 has no use because of #104.
RE #101:
Thanks!!
Everything is so easy! Want something new for CKEditor? Write a CKEditorPlugin! Does it need a filter? Great! Write a filter (also a plugin). Everything is in one place. No more info hooks where you define callbacks (watch the typos!), then write that callback, etc., etc... Now the interfaces you inherit from tell you exactly what to do.
Then there's the JavaScript. My God! The JavaScript! I can actually read and understand it first time around now... CKEditor helps too of course (see further down this comment).
1. Not sure if it's new, or how new it is, but I just opened the docs to see if there was a way to define them that would make them easier to alter/extend and then I found this (http://docs.ckeditor.com/#!/api/CKEDITOR.filter.contentRule) about the requiredContent property:
and this http://docs.ckeditor.com/#!/api/CKEDITOR.style
2. I thought so too, hence the DX comment ;-)
3. Yes consistency, I'll take it out again if you want to put this in a separate issue.
4. Yes it does :-)
5. Gotcha.
6. <3<3
7. <3<3
8. I was following the examples I found in core. You can use CKEDITOR.style for allowedContent as well, so if you want I can change it too in this patch (but I'll have to change it in
drupalimageas well).9. Yup.
10. Uhu.
11. Yeah it crossed my mind but I didn't do it eventually, will fix.
12. Then love is what it will get.
13. More love coming in!
14. Same comment as above ;-)
15. Only the label or also the plugin name?
16. See #102.16
17. Will do!
See #104
NR for testbot, afterward back to NW for todo's listed above.
Comment #109
jelle_sOk so about #101.8 & #101.14:
We could make
CKEDITOR.styleobjects out of them but CKEditor themselves defined it as a plain js object (see http://docs.ckeditor.com/#!/api/CKEDITOR.filter.allowedContentRules, 'the object format', and see the CKEditor source code). That means we have to either overwrite it (=> create an entirely newCKEDITOR.styleobject with the correct defaults) or find a way to parse it in to aCKEDITOR.styleobject. Either way, I would argue that's out of the scope of this issue? It would still be nice to get it in though. Same as the link plugin refactoring. It's still in this patch for now, but I'm open to creating separate issues for them both (link plugin &allowedContent)EDIT: I didn't have the time to look through the entire source code of CKEditor, but maybe a CKEditor developer could help us in the right direction. There might be code somewhere in CKEditor to parse such a string in to a
CKEDITOR.styleobject.Comment #110
jelle_sComment #111
jelle_sUnassigning for reviewers
Comment #112
attiks commentedNot sure if the preview is needed, it will make the dialog messy and complex, so I'm in favor of removing it.
Some nitpicks and we need some user documentation on the filters.
image2 = drupalimage in this context
drupalimage
This needs to be clarified on the filter as well, basically image style and responsive image style are mutually exclusive
We should bail out
Comment #113
wim leersGiven #1855412-43: Enable responsive_image.module by default for standard install profile, I think it's clear we can't get this in before RC either.
Let's make Responsive images in Drupal 8.1 blow people's minds. :) No need to rush this in now; we'll be able to do better work then.
This work is not wasted; this brings us to a great place to land this early in the 8.1 cycle :)
I think the preview is helpful to make the content creator understand what is going to happen:
Comment #114
Bojhan commentedAgreed with Wim here, the guidance from @webchick in the other topic is clear and allows for more breathing room to perfect this approach.
Preview is from my point of view required to make sense of this very complex interface already.
Comment #115
rainbowarrayJust so everybody is clear, this isn't only about responsive images. Right now you can't select normal image styles when placing images via WYSIWYG. You have to manually specify the height and width of the image. It's pretty awful.
I totally understand the concerns, and I'm on board with releasing this in 8.1. Just want to make sure the full picture is clear on what this issue is trying to do.
Comment #116
attiks commentedCan we at least change the existing ckeditor javascript so this can be fixed in contrib?
Comment #117
wim leers+1, but separate issue. Since it's a contrib blocker, I'm fairly confident this can also happen after RC1.
Comment #118
attiks commented#117 Done, created #2579979: Allow contrib to alter EditorImageDialog/EditorImageDialog and have custom attributes be stored
Comment #119
rainbowarrayIs there a way to do this without *requiring* responsive image module? Bonus points if it still works if responsive image module is enabled.
Comment #120
attiks commented#119 responsive image is not required, the image style part work independent. Since there's no change this will get added before 8.0.1, we will move it to the picture module, so at least it will be usable.
It would be nice if #2579979: Allow contrib to alter EditorImageDialog/EditorImageDialog and have custom attributes be stored gets committed so it is way easier to do it in contrib, but even if it doesn't get committed we still can override it.
Comment #121
rainbowarrayI think this is worth one last consideration.
An earlier version of this patch turned on responsive image module in the standard profile. But the latest patch... doesn't. Since turning on the responsive image module was the primary reason to push this off, and that reason looks to be no longer an issue, let's take one last look here. This is an improvement for WYSIWYG images even when responsive image module is turned off, so I think this is worth consideration.
I'll do a manual test.
Comment #122
rainbowarrayThe good news is that I got this to work when manually testing! The bad news is that it took some doing to do so.
1) With this patch applied, I can confirm that responsive image module is NOT enabled by default. Good!
2) By default, I can go to an article, I can use wysiwyg to place an image, and I can select an image style when doing so, and it appears to work. Good!
3) If I enable responsive image module, and I go to an article to place an image, I can only select an image style, not a responsive image style. :(
4) If I go to text filters, and turn on the responsive image filter in Basic HTML, and don't change its position, when I go to an article, I can't place any images with wysiwyg. Strange.
5) If I turn on responsive image filter for Full HTML, I think that worked right away. Good!
6) When I went back to Basic HTML and moved the responsive image filter after the image style filter, then I could select a responsive image style. That was confusing and not intuitive.
7) With responsive image filter on, the label for the selector was still image style. It would make more sense if that was labelled responsive image style.
8) When I view source on the output image, the responsive images have a src element, which will result in a double download, as described in #2481637: Use src in fallback image. I know the spec says there should be a src element, but when I checked with some RICG folks the advice I got was that at this time, probably best to leave off src when using Picturefill. Browser support is growing but not enough to risk double downloads.
So things I'd like to see changed:
- If I enable the responsive image module, the responsive image filter should be turned on and placed in the correct order in all of the default text formats. I shouldn't have to figure out how to turn that on: I've already decided to turn on the responsive image module.
- With responsive image filter, label for style select in dialog should be "Responsive image style:"
- Drop the src attribute in the img element output for responsive images.
Comment #123
attiks commented#122
1. ok
2. ok
3. is by design, filters are never enabled automatically, extreme example: what if a module implements a PHP filter
4. strange indeed
5. good
6. see 4
7. not good, needs to be fixed
8. this is out of scope for this issue and was introduced by #2348255: Provide option to use srcset and/or sizes attributes on img tag instead of the picture element which was approved by all of us. So if you/we want to change this, best to do it in a separate issue.
Thanks for the extensive review
Comment #124
rainbowarrayThis fixes the label in the dialog.
If the src in the source code is a separate issue, okay, we'll handle it elsewhere.
I retested this manually, and after enabling the filter, the image icon didn't immediately show up in the wysiwyg toolbar, but it did after I cleared cache. And then it didn't matter what position I had for the responsive image filter. Lots of things require clear cache, so that resolves my concerns there.
If we don't automatically activate filters for other modules, that resolves my concerns there as well. I'd rather this exist with some instructions than to not exist at all. We can make this easier once we finish all cleanup for responsive image module and can make it active by default.
In my opinion, this is good to go.
Comment #125
wim leersI think this is a super important issue, and I think you all did fantastic work pushing this forward.
But, it's just too much, too rushed in. Test coverage is completely absent. And in my testing, even fairly basic things are broken: when you edit the image style of an existing image, the dialog always shows "Large", because the client fails to send the
data-image-styleattribute to the server.I think this will be a splendid addition for 8.1, but to rush it in now and have it be a buggy, frustrating feature would be worse than not having it in 8.0. So let's do this in 8.1 :)
This needs test coverage.
Needs test coverage.
I don't think it's good to assume every site will want to use this. Some sites forbid images in the WYSIWYG editor altogether — it depends on how you model your data.
Plus, this would need test coverage.
Needs test coverage.
Needs test coverage.
Why this change?
This would belong in
imagemodule. And again, making too many assumptions. And again, missing test coverage.Comment #126
attiks commentedSince we basically split this issue, I'm going to postpone it on #2579979: Allow contrib to alter EditorImageDialog/EditorImageDialog and have custom attributes be stored, once that is committed we can add it in contrib first to test it, and move it back to 8.1.x
Comment #127
rainbowarrayFiled #2580695: Prevent responsive image without picture element from causing double downloads of images as a follow-up.
Comment #129
wim leersSadly, WordPress will ship with this before us: https://make.wordpress.org/core/2015/09/26/responsive-images-feature-plu... + https://make.wordpress.org/core/2015/11/10/responsive-images-in-wordpres....
We should definitely ship this with Drupal 8.1.
Comment #130
tancIt would be really great to get this in for Drupal 8.1. I just got really excited about the image handling in ckeditor in Drupal 8 then realised its fundamentally flawed without image style control and picture based responsive images.
Comment #131
wim leersAgreed.
The 8.1 branch opens in the beginning of January 2016 IIRC. Hopefully @mdrummond, @attiks and @Jelle_S will continue their awesome work then :) I'll be providing reviews for sure!
Comment #132
rainbowarrayThis is maybe my top priority for 8.1. We were nearly there before RC, I would think this would be doable.
Comment #133
rainbowarrayIt looks like #125 should be our starting point for picking this up again. We need a fair amount of test coverage to move forward. Tests are not my strong suit. Would welcome any and all assistance with that.
Comment #134
mitchalbert commentedAny tips how i can pick this issue back up? last patch is from 5 months ago
Comment #136
jon@s commented@mitchalbert were you able to pick this back up?
Comment #137
rainbowarrayFirst step is probably a reroll of the most recent patch. Entirely possible we'll need to do some updates due to D8 changes since last patch was rolled.
Comment #138
mitchalbert commented@Jon@s im working on rerolling the patch against 8.2.x-dev
hopefully done today
Comment #139
mitchalbert commentedRerolled the patch against 8.2.x-dev
some minor fixes were needed to get things working
Comment #140
almaudoh commentedFor testbot...
Comment #142
mitchalbert commenteddamnit, forgot to add the new files to the patch.
Not a git wizard here :( i try again
Comment #143
cbeier commentedAnd for the testbot again …
Comment #144
mitchalbert commentedHere is a updated patch. Fixed some issue's compared to previous patch
I was wondering, is the image_form_editor_image_dialog_validate the right place to alter the attributes?
Comment #146
jon@s commented@mitchalbert I'm currently porting your patch to a contrib module so that I can use it on 8.0.x and I figure that way it can get plenty of community testing before it gets commited to core. Currently I got most of the code ported, and managed to fix an issue with upcast/downcast in ckeditor (mentioned at start of #125), still need to work on the install/update functions especially addressing issues mentioned in #125. Also trying to determine if the template/css changes are actually needed and add some test coverage. I'll create a sandbox shortly.
Any chance your good at writing tests? It's really not my strong suit.
Comment #147
mitchalbert commented@Jon@s Great! can't wait to see what you did so far. You also update my patch or just sandboxing?
about writing tests; I didnt make any tests for D8 yet. Perhapse this issue is a good motivation to start with writing tests :)
Comment #148
rosinegrean commented@mitchalbert i tried to test your patch but got this js error:
Error: cannot call methods on dialog prior to initialization; attempted to call method 'option'
...""),isReady:!0,error:function(a){throw new Error(a)},noop:function(){},isFunctio...
@Jon@s what the status of the module ? is there a sandbox yet ?
Thanks
Comment #149
fkelly12054@gmail.com commentedI've been testing the inline responsive images module at:
https://www.drupal.org/node/2702981
works good for me. I posted some testing results there. Some evolved version of it would be great to have in core to assist with resolving the two-year old deficiencies noted in this thread. However, even as a contributed module it allows you to wrap an image in a style.
Comment #150
mitchalbert commented@prics
What version of drupal did you run the patch against?
For the module:
https://www.drupal.org/project/inline_responsive_images
Comment #151
rosinegrean commented@mitchalbert i'm using drupal 8.2.x
What i actually need is to have the width and height in the dialog for the inline image and tried to use this plugin:
http://ckeditor.com/addon/image
But it's not compatible with the core's image2 plugin, for which i can't find a way to override ... so i need to find another solution.
The patch with image styles looked like a good idea and i'm further exploring it.
Do you maybe have a suggestion for my issue ?
Thanks
Comment #152
rainbowarrayIt's been awhile since has work has been done on this, but I'm going to try my best to move this forward at DrupalCon NOLA.
The reroll in #142 was missing new files, and then #144 added those files back in but also made some additional changes. I think that's going to be hard to untangle. So I wanted to start over with a clean reroll. I'm glad to look at #144 to see if I can find what changes were made there to see if those should be incorporated.
This reroll is 39k, while the patch I based this off (#124) was 44k. I wanted to double-check what the discrepancies were, so I did a diff of the patches. This is messy, but if anyone wants to double-check this, here's essentially the conflicts I resolved in this patch. From what I could tell when resolving conflicts, these bits were things not really needed because some of the changes made in the #124 patch were resolved elsewhere in core.
This makes me think we'll want to go through this patch with a fine-tuned comb to make sure that everything in here is really necessary and is the minimum change necessary to move this forward. It's entirely possible some of the things this patch was trying to address before have been resolved elsewhere, even if they were resolved in slightly different ways.
Hopefully this is a good starting point to move forward.
Comment #153
rainbowarrayHmm. Well, manually tested #152, and this isn't actually working. No image style field is showing up in WYSIWYG. So that's sort of an issue. But hey, the patch applies cleanly?
Comment #154
rainbowarrayI took a look at the differences between #144 and #142, to get back the fixes made in #144. I'm still not seeing the image style selector in the dialog. I realized to test this I probably needed to run the update hook. However even with that, I'm still not seeing the image style selector.
The end result is that this shows why this patch so very much needs tests, as that would help to track down why exactly the patch isn't working.
Hoping to find some help writing tests during #DrupalConNOLA sprints.
Comment #155
rainbowarrayMissed adding in the files.
Comment #156
rainbowarrayGood news! I did some more manual testing, and this is indeed working both for image styles and for responsive image styles.
I needed to move the the image style filter towards the end of the list for this to work with the basic text editor, but for all I know a clear cache would have been necessary too. It's annoying this isn't turned on by default, though. Feels like I shouldn't have to know to turn on this filter for this to work. Not sure how possible it would be to change this though. I know this was discussed above in regards to responsive image styles, and it's not possible to have that filter automatically enabled because responsive images is an optional module. But the image styles filter seems like it should be on by default at the very least.
This still needs tests.
Comment #157
rainbowarrayTo get ready for putting in tests, I wanted to make a list of things this patch is doing, which should help us come with a testing strategy:
EditorImageDialog
Check if the form state has a src attribute, if not add the src attribute with the value of the file URI.
image.admin.css
Tweak the margins of the preview image, and set it to display: block.
image.module
Here is a big one! New function: image_form_editor_image_dialog_alter
There is a lot going on in here, but the short version is this adds the ability to select an image style within the wysiwyg image selector dialog. Here is how this goes down:
getBuildInfo['args'][0].So, validation!
Phew!
drupalimagestyle/plugin.js
This adds a drupalimagestyle plugin. Not sure it makes sense to walk through every single thing this does. That would get very long.
CKEditorPlugin/DrupalImageStyle.php
This takes care of connecting the drupalimagestyle plugin for CKEditor with Drupal. I think.
FilterImageStyle
This takes care of filtering text, looking for data-image-style and then transforming that into an img element that uses that image style.
image-style-preview.html.twig
Add a line break after the original image preview and the text that describes it: do the same for the image style preview. Feels weird to hardcode a br element in here.
drupalresponsiveimagestyle/plugin.js
This adds a CKEdtior plugin for responsive image styles.
responsive_image.install
Add data-responsive-image-style as an allowed attribute.
responsive_image.module
Alter the editor image dialog form to add a selector for responsive image styles. If the image styles filter is turned on too, disable that in addition to the width/height selectors. In the validation, build a preview image from the smallest image.
CKEditorPlugin/DrupalResponsiveImageStyle.php
This takes care of connecting the drupalresponsiveimagestyle plugin for CKEditor with Drupal.
FilterResponsiveImageStyle
This takes care of filtering text, looking for data-responsive-image-style and then transforming that into an img element that uses that image style.
container-inline.module.css
Allow container blocks inside of container inline to have display: block.
system.install
Add data-image-style as an allowed attribute.
Config for filter.format.basic_html.yml
Add data-image-style as a default attribute. Also add the image style filter config.
Config for filter.format.full_html.yml
Ditto.
CSS for Classy container-inline.css
This actually probably can't be changed anymore as this is frozen. But this does some things with inline container checkboxes, making some other styles for labels also apply to checkboxes too.
That is everything going on in this patch for better or worse. A lot of things to be tested.
Comment #158
rainbowarrayQuestions:
Comment #159
rainbowarrayI am making an executive decision that the items in image module that should probably not be in image module should be moved to the locations where other similar things are located. I am also getting rid of file statements no longer needed in these files, as well as some use statements that are not used anymore.
Comment #160
rainbowarrayThat interdiff was wildly inaccurate. Here is one that is not.
Comment #161
wim leers#152: I can confirm that those changes landed in other issues, so are no longer necessary. :) Although you'll still need to modify those JS files to allow the new
data-attributes that this issue adds.#158:
Because they use functionality provided by
imagemodule: (responsive) image styles. OTOH,DrupalImageCaptiondoesn't do anything image style-related, and can therefore live in the CKEditor module.Yes, it can still be disabled. But more importantly: functionality that needs a certain module to be installed should live in that module. We do this always, not just in this case. Only old/crappy code doesn't do this.
Well, I think there was at one point of this patch's life, but it got removed at another point, because we tried to still get it ready for Drupal 8.0, and since Responsive Images aren't enabled by default, shipping such config also wouldn't make sense. But… we totally could include such config in the Responsive Image module so that you get it as soon as you install that module, which would make sense IMO.
#159: Feel free to talk to core committers about this, but I'm 99% certain this does not belong where you just moved it :) Easy to change again of course.
Comment #162
rainbowarrayFYI, I will move the files back to the image module. I am currently working on a patch with dawehner that converts the filter plugin to unit testable code, and then adds a unit test for it. Will post once ready as a model for other tests we will need.
Comment #163
rainbowarrayThis moves the code back to whence it came. Bad Marc.
This also converts FilterImageStyle to unit-testable code.
I'm feeling stuck, so also posting my in-progress code so it doesn't get lost. I have my old version of the test in this patch purely to save the work I did on mocking up expected output. The unit test is in progress and not working yet. There are a bunch of services that need to be mocked up, and I'm feeling ind of overwhelmed by that. Hoping to find some help to move this forward.
Comment #164
rainbowarrayWrong interdiff. This is the right one.
Comment #165
rainbowarrayMoving this forward a little more with the help of dsnopek. Moving some of the FilterImageStyle->process logic into helper functions to make this easier to test (and to make it more clear what is going on in process itself).
Comment #166
wim leers+1!
Are you feeling stuck on other things, or only the mocking? Mocking can totally feel very overwhelming. Happy to help.
Comment #167
rainbowarrayI had gotten up at 5:30 a.m. to write this patch, and after an hour of work, I swore I posted a patch with my progress, but apparently something went wrong and the comment didn't post.
Anyhow, I had finished refactoring the process method to break it down into more easily tested functions. One of the tests had a bug, but progress.
Comment #168
rainbowarrayMade some progress with fixing the unit test, but still getting a weird error, could not figure out why with some help in sprint room. Could not get xdebug working so hard to track this down.
Comment #169
Bojhan commentedThis is pretty relevant for the media work.
Comment #170
rainbowarrayThanks to the help of alexpott and tstoeckler, we now have a working unit test for FilterImageStyle!
Will be refactoring FilterResponsiveImageStyle to create a similar test next.
Comment #171
rainbowarrayThis refactors FilterResponsiveImageStyle along the same lines as FilterImageStyle to make this more unit-testable. Also fixes a few minor things in FilterImageStyle.
Comment #172
rainbowarrayAdded a unit test for FilterResponsiveImageStyle, adapted from FilterImageStyleTest. Works!
Comment #173
rainbowarrayThis adds a test for image_form_editor_image_dialog_alter() to check that if we are using the imagestyle filter, that you cannot select the image width and height on the editor dialog.
I'll need to do the same for responsive images.
Not sure what else we want to test with the editor image dialog alteration.
We will still need to test and double-check how we add the data-image-style attribute as being valid, and the same for data-responsive-image-style.
Thanks so much for your help tstoeckler and dawehner!
Comment #174
rainbowarrayOne more patch to add a test for the responsive image dialog form alteration.
Comment #175
wim leersThis is looking great already! Thanks so much for pushing this forward! Here is a first comprehensive review :)
Did manual testing.
data-image-styleattribute:See the detailed analysis below, including a solution :)
These typehints that we add for IDEs are fine. But always use
, never use
Unnecessary newline.
This has strange indentation and, more importantly, is exceptionally difficult to read. Let's simplify this by storing some of these in variables, and then using the variables in this if-test.
This is literally adding an inline comment for every single bit of code. That's fine in custom/contrib, but not in core.
We only add inline comments for tricky things.
This suggests the first line is necessary for the second, but it is not.
This variable is kinda pointless, it'd be easier to read if this would just do
array_keys($image_style_options)[0]. Because it's only used once.s/array()/[]/, here and elsewhere.
This typehint is correct!
drupalimage/plugin.js,DrupalImage,"Image"drupalimagestyle/plugins.js,DrupalImageStyle,"Drupal image style",FilterImageStyle,filter_imagestyle,"Display image styles"vs
drupalresponsiveimagestyle/plugin.js,DrupalResponsiveImageStyle,"Drupal responsive image style",FilterResponsiveImageStyle,filter_responsive_image_style,"Display responsive images"This is inconsistent in multiple ways.
Let's change the CKEditor plugin labels from "Drupal image style" to "Image style" and from "Drupal responsive image style" to "Responsive image style".
Let's change the filter plugin title from "Display responsive images" to "Display responsive image styles".
Let's change the plugin IDs from
filter_imagestyletofilter_image_style. Or, better, change them toimage_styleandresponsive_image_style.These two statements need to be flipped. Because
originalUpcastwill return an upcasted element, which means<img src="…" data-caption="foo">will be transformed to<figure><img src="…"><figcaption>foo</figcaption></figure>.That means
element.attributeswill be checking the attributes on the<figure>tag in case of a captioned image.In other words: in case of a captioned image, this will be looking at the wrong element's attributes, and hence fail.
Similarly, if an image has
data-align="center", it will be wrapped in a<p>tag, which causes similar problems.Nit: outdated comment.
This code is also adding an inline comment for every single thing. Please only keep the essential comments.
We load the image styles, but then only look at their IDs. This function needs a better name.
These won't be generated.
"retained" vs "removes" -> that doesn't make sense.
Why assign these to temporary variables if we only use them in one place?
Why are these changes necessary?
Inconsistent array syntax. Let's use the newer syntax everywhere.
This is the only actual assertion.
I think we can assert several more things:
<select>allowing an image style to be selected, and the options it providesGreat test!
Nit: missing docs… or just don't do
$this->foo, and just do$foo. If you don't need to access them elsewhere in the test, there's no need to make them properties on this class! :)s/generated/expected/
Interesting! :) I would personally love this. But I'm not sure whether it'll be acceptable.
We'd also need a valid rationale to do this for
responsive_imagebut not forimage/standard.These
@fileheaders can be removed in all files. We don't need them anymore since 8.2.x. (YAY!)This is 90% duplicating what already exists in the corresponding code in
image.module. Let's put that in a treat inimage.module, then this can reuse that, becauseresponsive_imagedepends onimage.These should be
data-responsive-image-style.There's some more assertions here, but still not a whole lot.
Again same remarks here.
And this too could probably benefit from a trait to share some of the test code.
Oh, so you did do this for
imagetoo, but you put it in thesystemmodule. That's definitely wrong.OMG YAY!
Comment #176
sachbearbeiter commentedIt's so calm here since two months - is the progress going on in other issues?
Will the functionality be released in 8.2?
Is some kind of testing needed (i can't support this because of poor programming skills)?
For my clients this is a major important thing ...
Thanks
SB
Comment #177
anthony.bouch commentedHi All - have been lurking/watching this issue since it started. Have also tried once or twice to set aside the time to test, or event take a stab at making some of the changes/fixups recommend by @Wim Leers, after the great work from @mdrummond.
With the Drupal 8.2.0-Beta1 announcement - I guess I have a couple of questions.
Firstly, at a glance, this feature https://www.drupal.org/node/2421427 - also headed for core, seems to have picked up a little more momentum, and yet appears to offer significantly less functionality. To me the ability to be able to apply image styles/responsive images styles, to inline images is a killer feature. It means that several editorial scenarios can be catered for out of the box.
Has this issues stalled because of lack of development/test resource? Or because it's no longer relevant? Entity embed is awesome, but the approach here still seems like the ideal solution. Or am I missing something? Can this feature AND https://www.drupal.org/node/2421427 coexist in core?
I have a ton of respect for all the hours contributed here, and elsewhere in Drupal - and so always feel a little guilty when all I can offer timewise, is a comment, or the offer to test, but this is one feature/issue that I've been hoping would land for a while now, and so if nothing else would be interested to know what the current thinking is here.
Comment #178
fkelly12054@gmail.com commentedLike Blue_Waters I have been lurking (only since Drupal 8.0 was released though) in this three year old thread. And seeing the 8.2.0 beta announcement I too was concerned that the features highlighted in this thread will not make it into 8.2 ... which seems to mean that the great unwashed among us won't see them until 2017 or later.
Right now I make do by using:
https://www.drupal.org/project/inline_responsive_images
and also be adding the IMCE module besides ckeditor. The combination of these two let's me apply responsive styles to images and also BOTH upload new images and edit existing ones AT THE SAME TIME. (Also IMCE let's me reuse images I've uploaded by other means (FTP) in my content types ... a feature that is essential to me).
I would also echo Blue_Waters' "ton of respect" and guilt at not being able to do more, but just ask if we can get a quick status on what the current thinking is and what we can expect to see in 8.2.
Comment #179
rainbowarrayI'm sorry, this is on me. I got discouraged by the amount of work still necessary after I worked on this for almost all of DrupalCon's extended sprints. I would still like to get this in, but it seems challenging to do so by next Wednesday when I have a lot of other things on my plate as well. I would guess that if/when #2560457: Support drag-and-drop image uploads in CKEditor goes in, that will lead to a big merge conflict with this patch. Maybe not.
It is frustrating, because for the most part the functionality for this has been working since right before Drupal 8.0 RC1, but we've been lacking tests. I'm not the most knowledgeable on writing tests: I've tried to learn more, but it's still a pretty high bar. Particularly when it's hard to figure out what exactly needs to get tested.
I'll see if I can take another look and try to bite off at least a few chunks. I very much appreciated the feedback. I just found 31 points of things that needed to be fixed very intimidating. Maybe we can get this done one bite at a time.
Comment #180
wim leers#177 #2421427: Improve the UX of Quick Editing single-valued image fields is only related to this issue in that it is something that relates to images. It's not in any technical way remotely related to this issue. And yes, this feature can co-exist with that one. #2421427: Improve the UX of Quick Editing single-valued image fields is for in-place editing image fields. This issue is about images embedded in a body field via Text Editors, and does not touch image fields in any way.
#179: AFAICT there will be zero conflict between this and #2560457: Support drag-and-drop image uploads in CKEditor. And of course, this can totally be done one point at a time!
#177+#178: mdrummond is right, the only thing we really lack here, is test coverage. Test coverage ensures it's working correctly today, prevents it from breaking tomorrow, and overall makes this maintainable. You're more than welcome to help with writing the necessary tests!
Comment #181
rainbowarrayThanks for the update Wim that this should still be clear even with the other issues. That's good to know.
Making my way through the feedback items, starting with 1-9.
I have a new local setup for my core work. Getting this set up again held me back from digging into this for a while, but seems to be working again now. Hopefully the patches are still okay given that my setup is slightly different now.
More later.
Outstanding item that still needs to be addressed: excessive commenting mentioned in point 5.
Comment #182
rainbowarrayAdditional fixes based on feedback in #175:
10. Label, title and ID changed. Used the new ID in the update hooks as well, which is I believe the only place they're referenced.
11. That explanation makes sense about upcast. Flipped the order.
12. Updated this comment both here and in the corresponding responsive image class.
13. NOT ADDRESSED: As in my previous update, I haven't dug into removing comments yet.
14. The image styles are also used in the tips function at the bottom of this class, so not changing the name of this function.
15. Clarified the comment that these are being removed because they are no longer needed in the filtered output.
16. Moved around the comments to help clarify this.
17. Fair enough. Removed the temporary variable assignment.
18. NOT ADDRESSED: I don't remember. I'd have to look back through the issue history to better understand that.
19. Already tackled the array syntax conversion.
20. NOT ADDRESSED: Will tackle this later.
21. Thanks.
22. NOT ADDRESSED: I'll take a look at that.
23. Replaced generated with expected.
24. Leaving this as is for now.
25. Believe these file headers are all removed where possible now.
26. NOT ADDRESSED: To me it feels like a lot of overhead to add a trait for this, particularly when we'll still need some overrides (data-image-style vs data-responsive-image-style). Can look at that later if it seems essential.
27. Fixed.
28. NOT ADDRESSED: Fair enough. Will look later.
29. NOT ADDRESSED: Also will look later. For both 28 and 29, a general statement of "more assertions" is challenging to tackle. If there are any obvious things that you think should be tested, that would be helpful.
30. Moved this from system.install to image.install
31. I'm not entirely sure what this is referencing, but if you're happy, I'm happy.
So, here's the revised punch list:
- 5: Prune comments
- 13: Prune comments
- 18: Figure out what is going on here.
- 20: Add assertions
- 22: Look at missing docs/whether these are needed.
- 26: Determine if trait is needed.
- 28: Add assertions (guidance would be appreciated)
- 29: Add assertions (guidance would be appreciated
Comment #183
rainbowarrayIn #157, I went through what is going on with each file in the patch.
I noted this, with answers the question raised in point 18:
It's fair to note that's odd, not sure how much time we want to spend finding another way to make sure the text appears on a new line.
Point 22:
Yes, looks like we can handle this with just local values rather than fully documented class properties. Patch attached that does that.
Point 26:
The following methods have nearly identical code in FilterImageStyle and FilterResponsiveImageStyle
- loadImageStyles vs loadResponsiveImageStyles
- getImageInfo
- prepareImageAttributes vs prepareResponsiveImageAttributes
- getImageStyleHtml vs getResponsiveImageStyleHtml
It's possible this could be written in a generic way. Maybe we have a boolean parameter for whether we're dealing with images vs responsive images that could then handle the slight differences between the two functions without the method that calls this from the trait needing to know the implementation details.
Comment #184
rainbowarrayJust want to note that I've been thinking about point 26 some more, and I'm fairly dubious that it would be worthwhile to write a trait to share the image processing code with the responsive image module.
I know that 90% of the code is the same, and that's duplicative, but dealing with that 10% difference is going to be a pain. We're going to need to pass in some sort of parameter to trigger the responsive image version of the code output for these similar functions. However, the responsive image module is not enabled by default. So we'd have to account for that in determining whether to make use of that parameter or not. Between that and the extra boilerplate of writing a trait, I think the number of lines of code we'd write to avoid duplication would dwarf the couple dozen lines of code that are repeated. It doesn't seem like a good tradeoff to me.
If the code was exactly the same for images and responsive images, I'd feel differently.
If the responsive image module is enabled at a future point, perhaps adding that trait could be a future refactor.
Comment #186
gábor hojtsyComment #187
igorik commentedsorry for this my post, but I feel this as exactly one of the reason why there never will be Drupal 9.
So useful feature, it is implemeted in wordpress, but Drupal users probably never will be have it.
Drupal 8 is here for 8 months, and it is already losing it's chance to be interesting for others.
Now here will be 2 years of discussion about this issue, 700 comments, 3 big changes of the structure and after this time already nobody will be use Drupal.
#RIP_Drupal
Comment #188
rainbowarraySettle down, everything will be okay. There is some more testing work that needs to get done to get this in. I had hoped to get that done for 8.2, but did not manage to do so. I'm planning to continue to work on this in the weeks ahead, though, so that hopefully we can this in for 8.3. This isn't something controversial, we just need to make sure this is solid before we merge it.
Comment #189
sgdev commented@igorik, if you did a bit of research, you would know this functionality has existed in Drupal 7 for at least three years as part of the Picture module (https://www.drupal.org/project/picture). We use it on all our client projects, and it works really well.
The answer is really simple and straightforward. If this is a critical feature for you, don't upgrade to Drupal 8 yet. Drupal 7 is still fully supported and works.
Comment #190
sachbearbeiter commented@mdrummond - thanks for all the work you spend here ...
Comment #191
effulgentsia commentedGreat work on this issue so far! Promoting it to Major. I think it should have been prioritized that way all along. Image styles and responsive image mappings are a foundational Drupal concept, applied to image fields, and it's a glaringly missing feature to not have them applied to images within text fields.
Comment #192
erik commentedOut of curiosity, I tried out patch #183 against my 8.1.8 installation, which results in the onscreen error
'The website encountered an unexpected error. Please try again later.'
This error appears both on:
node/add/page and
admin/config/content/formats/manage/basic_html.
The syslog displays the following error:
Drupal\Component\Plugin\Exception\PluginNotFoundException: The "filter_imagestyle" plugin does not exist. in Drupal\Core\Plugin\DefaultPluginManager->doGetDefinition() (line 52 of /var/www/mydomain.com/dev/htdocs/core/lib/Drupal/Component/Plugin/Discovery/DiscoveryTrait.php).
Should the patch be ran against 8.3.x-dev and is the error there because of core 8.1.8 or is it for another reason?
Comment #193
rootwork@erik I'm sure it's because of the core difference. Try testing against 8.3.x.
@mdrummond Thanks for all your continuing hard work on this. It's really exciting to see it moving forward!
Comment #194
fkelly12054@gmail.com commentedComment #195
fkelly12054@gmail.com commentedcripes re. #194. I'm just an onlooker hoping this issue gets resolved. I would never change the version or priority (I don't even know how). Firefox hung on my computer and when I looked at the screen it appears I changed the version and and priority. This is not something I would do but I don't see any way to change it back or to delete my comment #194. If a moderator or someone in the know can fix it back for me I'd appreciate it. (edit to edit I just found issue metadata and think I've fixed it)
In fact I was contemplating whether to thank our core committer from #191 for boosting the priority on this. It is a feature that is badly needed out in the trenches.
Maybe in the interim between NOW and 8.3 a little love and attention could be given to:
https://www.drupal.org/project/inline_responsive_images
which, as a contributed module provides something of a work around.
And, maybe I'm missing something, but it does not seem possible to BOTH have ckeditor set up to upload and edit images at the same time. I use IMCE to work around this but it would be desirable to do both. Should I post that as a separate issue (say Feature Request). I realize you don't want multiple issues in one queue.
Comment #196
erik commented@fkelly
Would indeed be a nice alternative until this one is ready for core. :)
But the thing was that it didn't work well, it doesn't like the output Twig debugging generates: https://www.drupal.org/node/2770965#comment-11509195
Comment #197
rainbowarrayTried to get started on a reroll for this, but I have a composer-based setup for my core local, and composer install does not appear to be working for 8.3.x yet. So I'm kind of jammed on moving forward because of that. I can work against 8.2.x for now, but once this is rerolled for 8.2.x, I effectively won't be able to test this unless I set up a new local development environment just to work on this patch. I'm not keen to do that.
Comment #198
rainbowarrayGot some time to work on this today. Here's a new patch that addresses some bugs since I made some of the feedback fixes.
I've renamed the filters to filter_image_style and filter_responsive_image_style. Using filter_ as a prefix seems to make more sense when lined up against other similar filter plugins. Particularly because that ends up being used as the config file, and it's really weird to see a file named image_style that isn't the definition of an image style but instead is the definition of a filter. filter_ just seems a lot more clear to me.
I fixed a few other little glitches. Something is kind of off with the responsive_image side of things, but I'm not quite sure what yet. Something with the validation function is off. I'll try to track that down.
This is rolled against 8.2.x because the subtree split for 8.3.x isn't ready yet. Glad to update this once that's ready.
Comment #200
Anonymous (not verified) commentedI've applied the patch from #198 to my site, enabled the Pictures module, and setup the text format to use the new filter. Now CKEditor allows me to choose a responsive image style, but it seems to never be rendering the image. I've tried several filter processing orders, but none of them have fixed it. Is there some additional step necessary to get this working?
Also, just wanted to say thank you for all the work that's been done so far on this... I was really surprised when I found it wasn't part of Drupal Core, given how much of an emphasis was given to Drupal 8's responsiveness when it was being promoted, so it's nice to know that progress is being made toward making it responsive in the place where it seems--to me--it is most likely to come up. I look forward to it being in core, even if that isn't until 8.3.x or later.
Comment #201
afoster commented@JKerschner - I can't confirm is the same bug but contrib port of this work in https://www.drupal.org/project/inline_responsive_images
reports an identical bug where if you enable TWIG debug. https://www.drupal.org/node/2770965.
The Twig comments break the output and nothing renders, disabling twig allows the image to render fine. It's worth trying to see if disabling twig debug fixed the issue (I did the trick for me on the contrib module)
Here's a patch that reports to fix the bug which may be a possible basis for a fix here. https://www.drupal.org/node/2802013 This patch is currently untested.
Comment #202
guschilds commentedHey all,
I also found myself in the "I need this right now but I don't have the time or knowledge to bring it to the finish line" camp and it's apparent that I'm not alone, so I created a Simple Inline Responsive Images sandbox. As mentioned in the sandbox description, it's built primarily from the
FilterResponsiveImageStyleclass within the patch from #198, with the key difference of rendering all inline images through a single responsive image style rather than configuring the image style for each image. It currently works with Drupal core 8.2.0.As also mentioned in the sandbox description, thanks to everyone who has worked so hard on this! I feel a bit guilty creating the sandbox from it without contributing to the patch itself, but I hope it can at least provide temporary relief to others while you continue to focus on Doing It Right.
Gus
Comment #203
juancasantito commentedThe array short syntax changes somewhere between ~140 & 180+ in EditorImageDialog is causing some issues with applying this to 8.2.x. There's already a separate issue for that code style change, can we remove it from this patch?
Comment #204
juancasantito commentedIs this the only change in EditorImageDialog? If it is, then this should clean things up a little. That's the only piece added to that class. This also needed a re-roll, so no interdiff. Just re-roll and limiting what changed in EditorImageDialog.
Comment #206
juancasantito commentedComment #208
juancasantito commentedSo, this is a very large patch (>100k). Can we break this into two parts to make it easier to review? Maybe one for image module, one for responsive image?
For me, I just need the functionality from image module. And that is currently functional. The responsive part isn't functional, at all.
Comment #209
heddnThis is a much slimmer patch that only addresses the functionality in image module. It should make reviews and testing easier. We'll have to open a follow-up for responsive_image.
The interdiff is large, because it has a lot of code removed. I also removed a ton of out of scope short array fixes that were introduced in an earlier version. Which also helped a ton in getting this down to something more manageable.
Comment #211
heddnComment #212
heddnIssue summary updates and added follow-up for responsive_images: #2822389: Allow responsive image style to be selected in Text Editor's image dialog (necessary for structured content)
Comment #214
heddnSelf review. Does this need to add any cache context for image styles. Like if the image style is rebuilt, flushed or changed?
Comment #215
heddnIs the latest failure because of #1308152: Add stream wrappers to access .json files in extensions and/or #2770761: Derivatives should not be created on read-only stream wrappers?
Comment #216
heddnComment #218
heddnComment #220
heddnOK, I've opened a follow-up to address #2822589: Followup: Allow image style to be selected in Text Editor - add preview. This means the next patch will have even less in it. I'm moving the image style preview stuff into a follow-up. The reason is posted in the other issue. TLDR; there's enough style problems with image_style_preview that a follow-up to add it back in is a good idea.
Comment #221
heddnComment #222
wim leersThanks for the big push forward, @heddn! Here's a comprehensive review in return.
Why is this change necessary?
s/8001/8300/
Must also be wrapped in comments like this:
Hm…
core/modules/image/image.post_update.php, where you can also find a pre-existing example.file_image_styletext filter is not enabled for a text format. Well, because that's a new text filter added by this patch, not a single text format will have it.We should choose: either we upgrade
basic_htmlautomatically for all sites, or we should let existing sites continue function like they do. Arguments can be made either way. But the update that this is doing is not really helpful right now.(And I'm probably the one who wrote this originally! My bad!)
Should typehint to the interface.
This can be simplified to:
An example of exactly that pattern can be found at
\Drupal\editor\Form\EditorImageDialog::buildForm.Should be removed.
Second condition shoudl be removed.
Not clear enough. What about:
// Get the image (<img>) that is being edited on the client.There's no form element for
'dimensions', so this can simply be deleted. (I think that did exist at some point a very very very long time ago.)This container is no longer necessary if we're not doing the preview thing. If necessary, #2822589: Followup: Allow image style to be selected in Text Editor - add preview can add it back.
$this->t()Is picking the first one by default sane/correct?
We should triple-check whether we still need all this now that the preview is gone.
We don't "validate" that. We ensure that. This comment can be removed; the validation callback's comments already explain this.
Pointless comment. (Plus, it's wrong!)
ImageStyle::load($attributes['data-image-style'])This must use a relative file URL.
See
\Drupal\editor\Form\EditorImageDialog::submitForm()+ #1494670: References to CSS, JS, and similar files should be root-relative URLs: avoids mixed content warnings & fewer bytes to send.Must be injected.
s/array()/[]/
Why not call this
drupalimagestyleinstead?I think "override" describes better what's going on than "override".
This can be simplified by doing:
This is a new API that was introduced in 8.1.0, see https://www.drupal.org/node/2648056. For another conversion issue, see #2696771: Minor clean-up of \Drupal\ckeditor\Plugin\CKEditorPlugin\Internal::getConfig().
Nit: incomplete docblocks.
Nit: no FQCN here.
s/img/
/
or
s/img/image/
If we're going to be validating image styles, we're also going to need to validate file UUIds. Which this code does not. Nor does the existing
\Drupal\editor\Plugin\Filter\EditorFileReferencefilter. Of course, this sounds like a good idea. But we should apply it to everything consistently then, including the existing filter.So let's defer this to a follow-up.
This is also something
\Drupal\editor\Plugin\Filter\EditorFileReferencedoes not yet do. Again should be consistent. Let's move this to another follow-up.This is wrong. It could cause bubbling. It needs to be rendered in isolation. And it's then up to the calling code to import the bubbled cacheability metadata + attachments.
This must be wrapped in an
executeInRenderContext()call. Like so:Specifically, we need to do the same as what
EntityEmbedFilterdid:(See http://cgit.drupalcode.org/entity_embed/commit/?id=c248cda0da575d6a9f5f9...)
Let's give this a
$this->randomMachinename()Let's use
$this->randomString()$format->id()This is not testing very much.
This is only testing one case. This is not testing any edge cases.
Using a data provider would make sense here.
Is this change really necessary?
In both of these text formats, the new filter is configured to run before
editor_file_reference. I'm pretty certain that will break, becauseeditor_file_referencewill overwrite thesrcattribute. (Since #2666382: EditorFileReference filter: generate URLs for inline images.) This points to one big gap in testing: integration tests. I'd like to see aFunctionalJavaScriptTestBasetest where we have integration testing with actual verification that the inserted image gets the dimensions of the image style etc, and that after saving, the image still has those dimensions. I'm 99% certain that after saving it won't have those dimensions, due to the problem I explained here.Let's revert these changes?
Comment #223
wim leersTitle was a bit inaccurate. ("Responsive image style" used to be called "picture mapping", that's where the "mapping" word originated from.)
Comment #224
heddn1) That came in at #2061377-155: [drupalImage] Optionally apply image style to images uploaded in CKEditor 5. Removing it as it seems like a stray addition. Or maybe Marc can remember and we'll add it back.
2-10) done
11) This isn't a class, it is a module file. I don't $this is possible
12) removed a default so as to force the user to select something
13) removed
14-17 done
18) I do not think this is possible in a .module file.
19) I'm intentionally not introducing short array syntax. The rest of the .module file uses the older style, so I've stuck with that in this file. I think that is how we are supposed to do this, yes? If there are brand new files, I've adopted short array.
20) done
21) Don't understand the comment. Leaving things as is for now until I get clarification.
22) You mean drupalimagestyle, no?
23-25) done
26-27) a stub todo added, need to still open the follow-ups.
28) Still noodling on this comment. No changes just yet while I try to digest it.
30-31) done
32-33) agreed, no changes yet though.
34) reverted
35) weights altered.
36) 110% agreed.
Plus, we need a test of the post_update. But moving to needs review for the test bot. I'm going to put this to the side for a few days, in case someone else wants to jump on this and keep the momentum going.
Side note: we are down to 30kb from an original 102kb. I think this is shaping up nicely.
Comment #225
wim leersentity_embedissue. Or I can reroll this patch with just that part changed.Comment #226
heddnFlagging novice for 225's #21 & #22. Less novice is #28.
Comment #227
ada hernandez commentedComment #228
ada hernandez commented#22 it was already done in the last patch 224, #21 done, #28 done.
Comment #229
tkoleary commentedComment #230
tkoleary commentedPatch not working in simplytest.me
Uploading image no combination of settings submits the form and closes the modal, but no error appears.
Comment #231
tkoleary commentedComment #232
ifreeman commentedThis fixes several bugs to the core functionality of the recent patches:
1. Restore data-image-style attribute when inserting inline images (access ckeditor allowedContent as the array that it is, allowing the js plugin to do its job and apply data-image-style).
2. Transform image url during editor dialog validation to relative only after grabbing it from image style.
3. Revert a name change for the DrupalImage ckeditor toolbar button, allowing the drupalimagestyle plugin to load.
4.
Access ckeditor allowedContent as the array that it is, allowing the js plugin to do its job and apply data-image-style.same as #1.Other points:
5. Add more testing for image style filter and related javascript. Changed FilterImageStyleTest from unit to functional. The efficacy of the unit test seemed poor with the meat of the filter, getImageStyleHtml(), being mocked.
6. Fixed all CS violations.
7. I think the proposed functionality to automatically apply an image style rather than allow selection should be in core. Without that functionality, this issue only partially solves the intent of placing style-formatted inline images. I'm sure many site owners will not want to give style selection control to all users.
I propose adding a default image style selection to the filter settings, modifiable by those with
administer image stylespermission. Additionally, the image style selection in EditorImageDialog should similarly be available only to those with the same permission. Thoughts?8. image.post_update.php could still use coverage.
Comment #234
rainbowarrayI think in an ideal world it would be possible to select which image styles can be applied via WYSIWYG. I could certainly see a possibility for allowing different types of inline images, rather than just one. For example, images that take up the full width of a content block vs images that float left or right. I could also see that sometimes varying for different wysiwyg fields. Varying allowed image styles—whether that's per text format, per field, and/or per role—seems like a pretty significant scope increase. I'd rather see a simple version of this get in first, then add additional features like that in follow-up issues. This issue has already taken ages without a big scope increase.
Thanks so much for the work on this, ifreeman.
Comment #235
ifreeman commentedI totally agree that it should be a follow-up. I was commenting in reply to Wim Leers' #8:
To that, I think it's important enough to come in core. However I did not think through the possibilities as you have. Yes, the follow-up could be quite a complex issue.
Marking for review since the retest passed.
Comment #236
claudiu.cristeaSecond line should be left-aligned with the first.
It's obvious why the hook implementation lives here: When image.module is disabled, the feature is disabled too. However, even this solution is simple and ingenious, from an architectural point of view looks wrong. This is an editor functionality that hooks in another editor functionality. At least for me looks weird to see functionality belonging to editor module inside image module. For this reason I would move this hook implementation (+the validation callback) in Editor module even this mean to add an
I think it would make more sense. Let's discuss this.
s/getFilterformat/getFilterFormat
Off-topic: I wonder why
FilterBase::$statusis a public property instead of being protected with a setter and a getter.The image dialog can be exposed also to regular users. The admin might not want to show all the image styles to the user. Imagine that it's possible to have styles, used in other places on the site, that might break here the layout if are used. For this reason, I suggest that
filter_image_styleshould implementsettingsForm()method and allow site builders to restrict the list of image styles being used in that specific text format.Let's switch to modern square brackets array syntax.
This needs upgrade path test.
I don't understand the reason for those weight values. We cannot predict the weight of existing text formats, do we?
Let's use
$format_idfor the text format ID for more clarity. And$filter(the config entity) should be$format, right?I don't understand why prefixing with "Drupal".
The word 'button' can go to the previous line.
Unused statement.
The follow-ups should be opened.
s/Get/Gets
Still needs a description line.
"Text filter"? I think "Text format"
Let's cast to FilterFormatInterface
20 seconds is a huge interval. 10 or 5?
Why do we run JS instead of directly clicking on the element?
Comment #237
ifreeman commentedThanks for the quick review, claudiu.cristea. To your points:
Therefore, I won't move this.
Off-topic: Probably because status can be set by property during instantiation, although I haven't read into the underlying code.
While finding my code to paste above, I went ahead and replaced
'status' => 1with'status' => TRUEin the patch.core/modules/ckeditor/js/plugins/drupalimage/plugin.js
core/modules/ckeditor/src/Plugin/CKEditorPlugin/DrupalImage.php
core/modules/ckeditor/js/plugins/drupalimagecaption/plugin.js
core/modules/ckeditor/src/Plugin/CKEditorPlugin/DrupalImageCaption.php
core/modules/ckeditor/js/plugins/drupallink/plugin.js
core/modules/ckeditor/src/Plugin/CKEditorPlugin/DrupalLink.php
I imagine the other three plugins are not named such because they are from upstream CKEditor plugins. I imagine that is the motivation to prefix with Drupal, to differentiate from upstream plugin code.
HTML::load($text)andHTML::serialize($dom), but again, case sensitivity. Fixed class references.I left the empty uuid check in this patch, since it prevents an exception later on.
$this->format instanceof \Drupal\Filter\FilterFormatInterfaceis already true, so I'll just update the FQCN.Clicking on the button directly resulted in the same internal phantomjs exception as described in #2830485-12: \Drupal\Tests\outside_in\FunctionalJavascript\OutsideInBlockFormTest fails randomly, even with a wait of 25 seconds in place. Trying instead to submit the form was the same. This implementation was my third attempt and thankfully worked. I'm not sure why this succeeds where
->click()does not.Leaving as needs work due to #6 above.
Comment #238
naveenvalechaSetting to N/R for testing #237
Assigning to myself for #236.6
//Naveen
Comment #239
naveenvalechaInitial attached patch which changes the name of the post-update hook and rename of few variables b/c the update hook was failing on local. however the above patch passes b/c the update hook was not properly named.
//Naveen
Comment #241
naveenvalechaAddressed #236.6(Added upgrade path test.
// Naveen
Comment #244
rewted commentedSo I understand correctly, this feature is still under development and slated for the 8.4 release, or potentially can we see it sooner?
Additionally, it would be great if the Inline Image could also Link Image To (original file or other image style) just as we do with managing content types.
Comment #245
fkelly12054@gmail.com commentedSince this issue does not seem amenable to a programming approach anytime soon, was wondering if it would be possible to produce documentation about how we could use the source view in ckeditor to type in the proper codes to have responsive image styles in our content?
Comment #246
kingdutchThe
FilterHtmlUpdateTestchecks the allowed tags and attributes for basic_html after updates.This issue touches that list so I've amended the test expectation to also expect the
data-image-styleattribute.This also runs against 8.4.x instead of 8.3.x (patch applied cleanly).
Comment #247
phenaproximaRe-tagging.
Comment #249
pfrenssenThis no longer applies to 8.5.x now that #2870009: Update: Convert system functional tests to phpunit landed.
Comment #250
pfrenssenStraight reroll.
Comment #251
pfrenssenI'm going to work on this today to try to move this forward a bit. My plan for the day is:
Comment #252
pfrenssenFrom the review in #236 points 4, 7 and 8 still need to be done.
Point 4 (allowing to limit the image styles shown in the dialog) was deferred to a followup #2840462: [PP-1] [drupalImage] Restrict available image styles for uploaded images but I think this patch is not going to be usable without at least a basic way to define which image styles are used. The wysiwyg editor is often exposed to end users and it will be too confusing to see dozens of unrelated image styles there. In this issue we should add a simple form that allows to choose from the range of available image styles. We can keep the followup for more advanced use cases, for example allow all image styles if the user has the "administer image styles" permission.
Comment #253
pfrenssenThere is a method for directly accessing properties that are stored in the form state:
Two points here:
basic_htmlandfull_htmlbut ignores all other custom editors that might have been added in the site. It would be better to insert the new attribute whenever the <img> element is allowed.I tried this out and if the "Limit allowed HTML tags" filter is enabled and the
data-image-styleis omitted, then the image button will disappear from the wysiwyg as soon as the image styles are enabled.To avoid some WTF moments for site builders that are upgrading their existing sites, we can better allow this data property always, it should be harmless.
Using double parentheses in an if statement has no meaning in PHP. This is probably a leftover from a previous version of the patch that may have had multiple operators.
Let's order the use statements alphabetically.
Let's split the arguments on separate lines, as is the tradition.
attribute, whose values is one of the image style machine names: !image-style-machine-name-list.
', ['!image-style-machine-name-list' => $list]);
This looks strange split over 2 lines like this.
This else statement is technically not needed.
Stray empty line here.
Let's sort the use statements alphabetically.
There should be an empty line at the start of a class.
Hahaha this is hilarious :D
Sort use statements alphabetically.
{@inheritdoc} can be used here.
Comment #254
pfrenssenAddressed remarks from #253, except remark #14.
Comment #256
pfrenssenImplemented the settings form that allows to limit the image styles that can be chosen in the wysiwyg. This concludes all remarks from #236.
The only thing that is now not addressed is to disable the manual resizing of images that have an image style assigned to them. This is out of my comfort zone, I'm leaving this for the CKEditor wizards :)
Comment #259
claudiu.cristeaI barely remember this issue so, I went through the whole patch. Here's a review:
Let's add a label too.
'Image style ID'?If there's only one image style in
$image_style_optionswe should select that by default (because it's a required field), use'#type' => 'value'and show a message, like "The image will be displayed using @image_style_label image style". If the current user is able to to edit this text format, let's append a something like "Allowed image styles can be configured here.""Use image style" would be better?
Isn't this handled by the plugin JS?
s/$new_attributes/$attributes ?
I think
drupal-8-rc1.bare.standard.php.gzis the latest.This duplication doesn't make sense.
Not so nice to refer a deep nested value in this way. This would be more elegant:
And we should not use assertion messages anymore.
s/public/protected/
$this->assertNotEmpty(...)
$this->assertArrayHasKey(...)
s/public/protected
the local variable
$formatis not used anywhere, so we can get rid of it:20 seconds seems a huge amount of time. If nothing happens in 5 seconds, something very bad should happen there.
Also, looks a little bit strange to me that we're using 2 assertions just to wait. I'm not sure is correct, can you explain this?
Same long wait window.
Is this the same as #2831506: Minimal profile disallows modal AJAX tests under JavascriptTestBase? If yes, we need to link here and add a @todo. If not, we have to open a bug issue and link.
s/public/protected
$this->assertArrayNotHasKey(...)
And now the most complex part: What happens if you configure this filter with a text format and after that, the admin deletes one or more of the configured image styles? With the code from this patch, will crash in
template_preprocess_image_style(). Drupal 8 has implemented an API to ensure the consistency when some configs or plugins have dependencies on other objects (configs, content, themes, modules), this is done by implementing::calculateDependencies(). Unfortunately, for config entities (in this case the text format) with plugin collections (in this case the filter collection) we don't have a reliable mechanism in place that knows to act when a dependency of a plugin, member of collection, is removed. The issue that is meant to fix this is #2579743: Config entities implementing EntityWithPluginCollectionInterface should ask the plugins to react when their dependencies are removed. But till that complex issue is in, we have to deal somehow with this. But how? Is it OK just to replace with an empty string? I feel that would be the most natural thing to do. For this we need a check in this method (or even in the caller).Comment #260
pfrenssenThanks for the review! I still have this on my plate at work so I have time to work on this this afternoon.
Comment #261
pfrenssenThere was a failure and a coding standards warning about the
plugin.jsbeing ignored. This patch is taking care of that so this can have a go on the bot while I address the remarks from @claudiu.cristea.Comment #262
pfrenssenComment #263
pfrenssenComment #265
pfrenssenIt doesn't seem to be, none of the options seem to influence eachother. If I create a brand new filter format, enable all the image related options, and then finally enable "Limit allowed HTML tags and correct faulty HTML" then the <image> tag is not present in the whitelisted tags.
That's correct in fact, it is one month newer. I did some research and it seems intended specifically for testing the RC phase of Drupal 8.0 (ref #2592665: Create RC1 database dumps). But then it means that the "drupal-8" one is also from the RC phase, and older!
So I did some more research, and the
drupal-8.bare.standard.php.gzappears to be 15x as popular asdrupal-8-rc1.bare.standard.php.gzfor commits that are testing the upgrade path and were added in 2017:So I guess the "drupal-8" is fine for now :)
Fixed remarks from #259 up to point 7. The other points are for tomorrow!
Comment #267
pfrenssenFixed all the remarks.
Regarding your point #19, I added the config dependency in the standard way, and this seems to work fine, this is the page I get when I try to delete an image style:
Comment #270
pfrenssenFix failure.
Comment #273
pfrenssenFixed an error in the "About text formats" help text, and the test failure. The
$modulesparameter in the test needs to be public for the moment, until #2822382: Make every $modules property protected on classes extending BrowserTestBase and KernelTestBase is fixed.Comment #275
sumanthkumarc commentedIs this https://www.drupal.org/node/2909023 related anyway to this issue?? where double click on image doesn't open image dialog, because wrappers around the image are gone.
Comment #276
vijaycs85Over all, the patch does what's in IS. Attaching the gif of manual testing.
minor: I believe it's a good use case to replace array_map with array_column. See #2902018: Use array_column instead of array_map where possible in the Workflows module for example.
Is there any special reason we are not extending CKEditorPluginBase class as it has first 3 methods there already?
Comment #277
vijaycs85Comment #278
phenaproximaDidn't get a chance to review the full patch, but found a few things:
$form should be type hinted as an array.
What will happen if the format doesn't have the image style filter configured at all?
That doesn't seem right. Surely they should be able to choose "no image style"?
$form_state should not be passed by reference.
Nit: There's an extra blank line here that shouldn't be :)
Comment #279
ifreeman commented@pfrenssen: I see you removed the duration from the js clicks in AddImageTest. They were needed for me when I was running tests. See #237-17 (my answer to claudiu.cristea the first time he inquired about the duration). In any case, I will be doing some testing/work on this next week and will see if the tests go through for me again.
Comment #280
ifreeman commentedComment #281
ifreeman commentedReview:
For the sake of extensibility let's instead emit all the new form elements and set our permission/logic decisions in the #access variable.
I agree with phenaproxima in #278-3. I did a quick check in this issue and didn't see a definitive requirement to force users to use only image styles. I could see that being a desirable site configuration choice, but that can be left for consideration in a follow-up if anyone feels that way.
Let's add target="_blank" so the user is not eternally cast out from their in-progress content edits should they visit the link.
Making new simpletest tests is counter-productive to #2735005: Convert all Simpletest web tests to BrowserTestBase (or UnitTestBase/KernelTestBase). This test will work as-written with phpunit.
More readible asserts exist for these.
When I wrote this I wasn't aware of the `::waitFor___()` functions.
All the other ckeditor plugin.js files now have plugin.es6.js counterparts. Do we need to write one as well? I asked around a bit and was told "I don't know" a few times.
+++ b/core/modules/image/src/Plugin/Filter/FilterImageStyle.php @@ -0,0 +1,319 @@ + $list = new TranslatableMarkup('<code>' . implode('</code>, <code>', $image_styles) . '</code>');Concatenating translatable strings is not allowed, use placeholders instead and only one string literal (phpcs error).
Comment #282
ifreeman commentedTriggering testbot to see if random failures remain.
This patch addresses all of #281 (except point 7) and the following:
Passes phpcs and eslint.
The only open question now is #281-7, since #253-14 was relegated to a follow-up.
claudiu.cristea, was #259-19 answered to your satisfaction? See #2061377-267: [drupalImage] Optionally apply image style to images uploaded in CKEditor 5.
Comment #283
ifreeman commentedComment #284
ifreeman commentedUnlinking related issues that are already children.
Comment #285
mahalingam_cs commentedApplied patch from comment # 282 and it worked as expected. Attached a recording of test.
When the image is set to large : data-image-style="large"
Thumbnail : data-image-style="thumbnail"
Comment #286
anthony.bouch commentedI applied the latest patch against both 8.4.x and 8.5.x dev branches and tested inline images with the default styles, as well as newly created image styles - including changing images from one style to another between edits.
Everything works as expected, with one snag.
When the 'Display image styles' filter is enabled for a text format, the filter appears at the bottom of the list of filters, which I believe is where it should be.
See 'filter-settings-before.png'.
However, after saving and then re-editing the text format configuration, the 'Display image styles' filter has moved up into first place - which won't work (a subsequent filter processing step will re-process the image data-image-uuid and replace the img with the source 'inline' image and not the processed style image).
See 'filter-settings-after.png'
In any case, with the filter in the correct order, all appears to be working well.
Comment #287
anthony.bouch commentedOkay so the problem with the position of the 'Display image styles' filter was caused by 'not' running the db update after applying the patch. The db update calls post_update and enables the filter for Basic and Full html text types - with the Display image styles' filter in the correct location, as last in the filter list.
Definitely not a show stopper, but I guess something to keep in mind if the filter is not enabled by default?
Comment #288
anthony.bouch commentedI have a couple of questions related to this issue.
The first, are there any objections to the status of this issue being changed to 'Reviewed and tested by the community', if not 'fixed'? Or will ifreeman's note in #282 on '#281-7' block this?
The second relates to the new Media initiative. Like a lot of people, we've been following the excellent and exciting work around the new Media initiative, including Dries' latest post here at https://dri.es/an-update-on-the-media-initiative-for-drupal-8-4-8-5 . I don't believe the new Media API and the two new 'Image' and 'File' media types are technically mutually exclusive of this fix/issue correct? That said, I've seen various threads that describe moving from 'file-based' images, to the new Image media type. I'm also assuming that there will eventually be either a contrib, or core equivalent to 'Entity Embed' (mentioned by David Reid in #76) for Media - supporting WYSIWYG/CKEditor embedding of media entities. So the question is, does any of this negate, or reduce the importance of this issue/patch? I ask because it still seems like an incredibly valuable feature to have in core, and that there would be nothing wrong with giving users/site builders the choice between file-based image embeds (with image style selection thanks to this patch), and Media entity embeds (with image style choices made via the Media type field and formatter definitions).
Thoughts?
Comment #289
sandervd commentedJust added a check to the latest patch, assuring that the file uuid belongs to a existing file. In its current form a fatal error is thrown when the data-entity-uuid is set to a uuid of a non-existing file (users could potentially edit the html).
Comment #290
phenaproximaI found virtually nothing to complain about in this patch. Truly fantastic work: the code is clean, elegant, and very useful. I'd like to see this get in for 8.5.0, but I don't think it's going to be committed without tests. I don't think we necessarily need a JS test -- just something that proves the filter actually renders the image style the way it's supposed to.
Rather than keep 98% of the method in an if statement, can we do an early return instead? Something like:
Nice! I didn't even know this existed :)
If $image->isValid() returns FALSE, the returned array is going to have a bunch of null values. isValid() returning FALSE usually indicates some sort of error condition, so I think we should log a warning, or something, if that happens, rather than silently returning an array of null values.
'prepareImageAttributes' doesn't really communicate what this method actually does. How about 'cleanImageAttributes' or 'removeImageStyleAttributes' instead?
Comment #291
claudiu.cristeaThe patch from #289 is wrong because is missing some parts. This interdiff is against #282.
Comment #292
claudiu.cristeaHere I share a 8.4.x version of #291.
Comment #293
claudiu.cristeaSorry the right 8.4.x patch for #291 is this.
Comment #295
phenaproximaNeeds a reroll against 8.5.x.
Comment #296
claudiu.cristeaThe patch for 8.5.x is #291, and that applies. The patch for 8.4.x is in #293 and that applies as well.
Comment #297
phenaproximaAh, sorry about that, @claudiu.cristea. Carry on :) This is a pretty shallow review, but it's a great patch and I'd like to see it land as soon as possible :)
What happens if the format does not have the filter_image_style filter? Will $filter be NULL? Should we return early?
Typo in "configuration".
Nit: There's no need to keep $access_manager in its own variable. We can just do
\Drupal::service('access_manager')->checkNamedRoute(...)Micro-optimization: If $access_filter_status, $access_administer_styles, or $access_filter_form are FALSE, there's no need to generate this link. So we should wrap all of this in an if statement.
Rather than wrap the entire function body in an if statement, can we return early if $form_state->getValue('fid')[0] is empty?
Same here. Just return early if $image_style is empty.
We can remove the $carry === NULL check if we pass 0 in as the third argument to array_reduce().
This probably needs to be refactored in ES6, using core's ES6 tooling.
Is there any particular reason to not simply add the image style functionality to the Drupal Image plugin, rather than bother overriding it? If the Image module is not enabled, the data-image-style attribute will just sit there harmlessly. It seems like it might be simpler than fully overriding the plugin.
What if the format doesn't have the filter_image_style filter, though?
Loading the image styles is quite heavy; Let's just use $this->entityTypeManager->getStorage('image_style')->getQuery()->execute().
This should probably throw an exception or something if $image->isValid() is FALSE.
This seems like a dangerous road to dependency hell. To me, it seems perfectly acceptable to silently ignore an allowed image style if it doesn't exist.
Comment #299
anthony.bouch commentedHi All,
Curious to know what the status, or current thinking is for this patch? Is it still relevant? Or has it been overtaken by an eventual 'media embed' plugin?
The need is great, as while we can limit the total size and dimensions of an inline image via the current inline image filter, it would be great to be able to select from an image style, with additional class/data attributes applied for styling images accordingly.
At this end we can offer to test, and review.
We're swamped with other work and commitments (as I'm sure are most of the people subscribed to this issue), however, if someone could offer a little guidance, or clarify the future of this patch as a feature when compared to the overall media initiative (i.e., is it still valid to have a direct image upload filter, with image style selection vs. focus on a media embed plugin?), as well as clarify what would be required for this to be accepted into core, then we'd be willing to financially sponsor a developer or organization to do the work.
We're also aware that we can't 'pay for patches', and that ultimately the decision to commit the patch relies on the reviewers/committers themselves. That said, there have been several detailed patch reviews above, and we're hoping that it should be possible to agree on what's required if this patch is still relevant, and can be ready for the 8.6.0 Feature Freeze: Week of July 18, 2018.
Thoughts, suggestions, opinions greatly appreciated.
Comment #301
claudiu.cristeaStraight reroll of #291. Will address #297 later.
Comment #303
claudiu.cristea@phenaproxima
#297.1: Fixed. Just a note,
$filter = $editor->getFilterFormat()->filters('filter_image_style')is always returning the plugin, even that text format is not using it. Just that$filter->statusisFALSE.#297.2: Fixed, simplified the phrase.
#297.3, 4, 5, 6, 7: Fixed.
#297.8: This I can do but see the next point:
#297.9: This would take too much for me, being inexperienced with CKEditor API. Could you ask somebody from the JS team to handle this?
#297.10: That is OK. As I told before
$format->filters('filter_image_style')is always returning the filter but with status FALSE, if the filter is not in the format.#297.11, 12, 13: Right. Fixed all.
I also, switched to
WebDriverTestBasein JS test.Comment #305
claudiu.cristeaFixing the tests and #297.8.
I prefer the someone else, skilled with JS to handle #297.9.
Comment #307
claudiu.cristeaFixing test and removed a duplicate line. #297.9 still needs a skilled JS developer.
Comment #308
claudiu.cristea@phenaproxima,
Ref #297.12:
This change, applied in #303, is wrong. It can be that, accidentally, an image is missed from the file system and then boooom! Insted we should output, as normal, the markup which will render as a broken image src. This is the normal behavior.
Reverted the change.
Comment #309
claudiu.cristeaA better approach that checks also if the file exists as entity in the database.
Comment #310
mlncn commentedThis works!
JavaScript looks OK but i'm not an expert either.
And the patch applies to 8.6.1 so can be applied to 8.6.x-dev at the same time as it is applied to 8.7.x-dev.
Next step: Responsive image styles from the WYSIWYG? :-D (in a new issue!)
Comment #311
phenaproximaPatch still needs review, sorry...
Comment #312
phenaproximaMore to come...
Can we move this to a utility method of FileImageStyle, to keep things encapsulated? Something like
$filter->getAllowedImageStyleOptions();would be cool.Shouldn't #default_value match #empty_value if no image style is selected?
Why is this needed?
Is it possible to use $editor->getFilterFormat()->toUrl('edit-form') here, and determine access using a generated Url object, so that we don't need to have this code know about Filter's internal routing details? The FilterFormat entity does define an edit-form link template, so in theory it should work...
Let's call this key 'configure_link' or 'configure', since it's clearer than just 'link'.
I feel like this should be in the form_alter, not the validation callback. Is there any reason it's here rather than there?
References into a form state are not great; let's remove that ampersand and use $form_state->setValue('attributes', $attributes) at the end of the function if needed.
Nit: I don't think $file is used elsewhere in the function, so we could collapse this into a single line:
File::load()->getFileUri()Comment #313
phenaproximaThis seems a bit limiting. What if we just updated every format which has filter_html enabled and allows the img tag (in other words, remove this in_array() check and the entire contents of the if block)?
Nit: "HTML" is an acronym and should be all-caps.
The code in this file looks right to me, but it should probably be automatically reformatted using Prettier, and verified by a JavaScript maintainer.
This might be a good place for the Image module to override and extend the implementation of the main 'drupalimage' plugin in order to add image style support. I explained this "plugin hijacking" technique in https://medium.com/p/94da0c31f095. Doing it that way may enable us to simplify this patch significantly (for example, we may be able to get rid of the form-alter stuff). On the other hand, that might be make it a little harder for contrib to extend the plugin. Just thought I'd bring it up as a possibility.
I'm not sure we need to call drupal_get_path(). It lives in the image module, which is always in
core/modules/image, so I think we can hard-code this.Let's change this to an early return if stristr() returns FALSE, so that we don't need to indent the entire body of the function.
Why aren't we querying for img tags specifically? We should definitely do that in order to prepare for the Media module's forthcoming generic support for embedded entities. And why do we need the data-entity-type attribute?
in_array() should always be called with TRUE as the third argument.
This method can be removed; it's not really adding anything.
This is also redundant and can be removed. Calling code should just use
array_keys($filter->getAllowedImageStyles()).This isn't quite accurate.
Can the @return documentation be expanded to explain what the array will contain? Undocumented arrays aren't great. :)
I think this doc comment really needs to be expanded. Why would this be called? What attributes will be removed? It's not clear why a DOM element is passed in an an array is returned; how will calling code use this method?
This is potentially useful elsewhere. I think it should be made a public static method of the \Drupal\Component\Utility\Html class -- maybe attributesToArray() or something like that. If not now, let's open a follow-up for it.
I feel like checkboxes would be preferable UX here if there are 10 options or less; otherwise a multiple select. The usability team's input would be helpful here.
I don't think we should be exposing the image style IDs in the UI like this -- they are of interest mostly to developers. It's trivial for us to display the actual labels, so let's do that instead. And if all image styles are allowed, we should just say "Any image style may be used", rather than listing them all.
Also, the information here is incomplete. It seems that the data-entity-uuid attribute, at least, is also needed. So I think this is not quite completed yet.
The post-update hook is doing a whole bunch of work, and I'm not sure this test coverage is thorough enough. Considering how dangerous update hooks can be, maybe we should also assert that only the correct formats were updated? Or that the new image style filter was actually enabled? Plus anything else we could check on?
Comment #314
heddnComment #315
heddn312.1-2, 312.4-5, 312.8 addressed.
313.2, 313.5-6, 313.8-12, 313.16 addressed.
313.14 follow-up opened,
That leaves outstanding:
312.3, 312.6, 312.7
313.1, 313.3, 313.4, 313.7, 313.13, 313.15, 313.17
Comment #316
heddnOK, this picks up the last few long hanging fruit.
Outstanding:
312.3
313.4, 313.7, 313.17
Comment #318
heddnComment #319
heddnWrong file. Interdiff was right. Here's the right one. And if the tests pass, I think I leave the rest for someone else to address.
Comment #321
heddnRemoved some stray files that made it into the last few patches.
Comment #324
heddnDo we need to add anything to the description of configuring the filter weight/order per #222.35? Actually, that seems more like a follow-up issue for that filter, not this one.
Another finding, if someone uses this filter in combination with FilterHtmlImageSecure, the image gets replaced as it thinks the image is external. It does this, because the image style variation isn't created yet and when it does its getimagesize check, it fails.
Lastly, here's a small change as a result of my manual testing. Hopefully that fixes the automated tests too?
Comment #326
heddnI backed off on changing 312.8 and added a comment. Also added a setConfiguration override to handle the checkboxes vs select list.
Comment #328
heddnThe update tests now pass green. So I think this should come back on the testbot too. With that, I'm going to leave the remaining points to someone else.
Comment #329
Anonymous (not verified) commentedSorry guys but there is a typo in the Proposed resolution description
You say we have to add data-imagestyle but it's data-image-style
For those who don't want to read everything, it will be more clear ;)
Comment #330
dydave commentedFixed typo in issue summary, as mentioned in #329.
Comment #331
slefevre1 commentedWhat's the latest patch for 8.6.x?
Comment #332
dbielke1986 commented...sorry... wrong content - can be deleted
Comment #334
claudiu.cristeaReroll for 8.7.x.
Comment #336
mecano commented#328 broken in 8.6.15, does #334 works for some of you? I still have to try on vanilla install, because of fuzzyness in applying patches one after the othernevermind forgot to clean caches, uh...
Comment #337
dbielke1986 commentedIt would be nice if there is a chance to set the default style which will be displayed in the dialog.
I was not able to set this with the help of the hook_form_FORMID_alter()
Comment #338
jcnventuraFixing the deprecation that made the test in #334 fail.
Comment #339
jcnventuraComment #340
stewestI've used / tested the patch in #338 and the Inline Styles config for the Text formats appears and also when adding / editing an image - you can choose the image style.
However, when rendering - the original image is used and not the new image style version.
src="/sites/default/files/inline-images/project-version.jpg" expecting ../files/styles/...
Should we be updating the templates?
Comment #341
stewestSorry, not rtbc, but needs work
Comment #342
stewestIt works! I changed the order so that the Display Image styles was last in "Filter processing order".
It now shows the correct image.
I'm using 8.7.6
Comment #343
stewestI probably shouldn't have changed the version.
Comment #344
wim leersAt minimum, this patch will need a reroll :) It doesn't apply to Drupal 8.8.
Comment #345
joegraduateRerolled #338 against 8.8.x (@ f0e313a4).
Comment #346
franknoel commentedI second #337, it would be great to be able to select a default image style instead of the "none" option.
Comment #348
rensingh99 commentedComment #349
rensingh99 commentedHi,
I have reviewed the patch #345 and it worked as designed.
I got some errors that are not as per Drupal coding standard.
I fixed those errors and uploaded the patch.
Thanks,
Ren
Comment #350
sébastien-frHello, I would like to test this patch but I can't. Could you explain me how you do ?
I know how to use composer and how to apply a patch.
Here is my issue :
If I try to install with composer :
composer create-project drupal-composer/drupal-project:8.9.x-dev drupal-8.9.x-dev --no-interactionComposer Install a 8.7.10 version.
If I download the drupal 8.9.x-dev here : https://www.drupal.org/project/drupal/releases/8.9.x-dev
I can install without composer the drupal 8.9.x-dev. When I try to apply patch with composer :
I have somme issues :
Your requirements could not be resolved to an installable set of packages.
Comment #351
bramdriesenNeeds work because the patch didn't apply.
Comment #352
sébastien-fr@BramDriesen =could you explain me how did you test it ? What composer command did you use ton install 8.9.x-dev ?
Comment #353
aaronmchale@BramDriesen see the instructions at https://www.drupal.org/node/3060/git-instructions/8.9.x/nonmaintainer which should get you started, you'll likely also need to run
composer install(which isn't mentioned on that page), but this issue isn't the right place to get support for applying patches, if you need any additional help you'll find a lot of great resources and various places to get one-on-one support at https://www.drupal.org/support.Comment #354
claudiu.cristeaReroll for 8.8.x.
Comment #355
r_h-l commentedPatch in #354 addresses part of the issue but not all:
#1 is as expected, #2 should be solvable by duplicating the code used to alter `image_dialog` to alter `media_dialog` with some logic to make sure there is an image field to target. #3 is trickier, but with the advantages of the 8.8.0 Media Library Integration and the Focal Point module, should be investigated. The relevant file looks to be `core/modules/media_library/src/Plugin/views/field/MediaLibrarySelectForm.php`.
I will poke at this when I have time, though this may be something to bring to the Media Library Team's attention?
Comment #356
claudiu.cristeaLet's revive this!
I did a comprehensive check of remarks from #312 and #313, which are the latest reviews, and fixed the ones that were missed along the road. I'm gonna add here a list with all points, the status or a comment.
#parentsin order to make the selected value an image attribute, nameddata-image-style, in the same as other image attributes, such asdata-alignorhasCaption. SeeEditorImageDialog::buildForm(), that is doing in the same way for the other attributes.data-image-styleattribute to the<img ...>allowed HTML forfilter_htmlfilter.Comment #358
karolus commentedI was able to get patch #356 to apply on a dev instance.
Per R_H-L in comment #355, it would be good if this (or similar functionality) could be applied to images added from the core Media Library. Right now, as it stands, I've moved sites over to full media management.
Additionally, for performance reasons with large images, I use responsively served images inline. Currently, I have this working through contrib using Entity Embed and File Insert, but it's a bit of a sub-optimal experience. Would be be possible to have a selector that would target the Responsive Image Style rather than the Image Style?
Comment #359
claudiu.cristeaFix coding standards & try to fix the test. It's weird because the #356 broken test is not crashing locally.
Comment #360
karolus commented@vinyl_roads
If you want to test the patch, it may depend on your build's setup. I have one set up using the Composer Scaffold method (currently at the shipping 8.8.1 build), and first, what I do is update to Drupal 8.9.dev by:
composer require drupal/core:^8.9@devThen, in the VM:
drush updbTo apply the patch, you may need to then run:
composer require cweagans/composer-patchesThen, add this under
extrain your composer.json (latest patch):With this done, run
composer install, and thendrush updb. You should then be able to see this option under Text Formats and Editors.Comment #362
claudiu.cristeaMoving the update test in its own class as they should use different fixtures.
Comment #363
pfrenssenLast interdiff looks weird but the patch is OK. The interdiff shows that the test has been copied, and then shows what was removed from the original and the copy.
I reviewed all changes since the last RTBC and had a quick look through the rest of the patch, and everything looks OK to me. I cannot RTBC this though because I worked on it.
I just found a nitpick:
This should be "The drupalimagestyle plugin provides the button for us."
Bit curious why I am excluded from the draft credit, I spent almost a whole week of work on this :-/
Comment #364
kualee+1 RTBC
I have applied the patch in #362 on both a D8 vanilla site and my current project, they are both working as expected.
Thanks for all the works everyone!
Not sure whether #358 and #363 need to be addressed before the status can be changed to RTBC, so I will leave it as Needs review
Comment #365
sachbearbeiter commentedI'm looking forward! Thanks a lot for your work ... looks promising :)
Comment #366
dbielke1986 commentedThis is a great patch, which should definitely be included in the standard of the module.
One more thing I would like to point out though:
You can assign an ImageStyle to an image initially or afterwards, but once a style has been selected, it cannot be replaced by "none" anymore...
Is there a solution for this?
The reason is the following:
We use the styles to perform lossless image compression. It happens from time to time that an optimization does not work or produces a faulty image. To get around this error, I would like to switch to "no" style.
Comment #367
goodboy commented#362 patch works fine
Comment #368
gaëlgThank you everyone for this hard but useful patch!
I see that the height and width attributes get "hardcoded" in the HTML field value. Is it a bug? Or is it useful to output the image at the right size in the CKE widget, like it seems to me? (it's ignored when the field is displayed in front)
If it's on purpose, what if I change my image style dimensions afterwards? The image would still output with the former dimensions in the edit form, right?* Has this edge case been thought already? (and maybe seen as an acceptable tradeoff?) I find no comment about it in the patch.
*Edit: yes, I got the expected faulty behavior on simplytest.me
Comment #370
gaëlgHere's a patch for #366 and #363. It needs review, and some work might be needed for #358 and #368. Maybe in follow-ups?
Anyway, we also need a reroll for 9.1.x.
Comment #371
gaëlgAnd here's my try to reroll.
Comment #373
gaëlgI tried to work on #368. But before I go further, I'd need some feedback on it.
It seems like it should be possible to decorate upcast() and downcast() CKE methods from plugin.js to get:
1) an HTML tag with width and height attributes used for the CKE preview
2) an HTML tag without these attributes used for storage (and CKE "Source" button) (for the style-related part, only the data-image-style attribute would be stored in database)
On downcast (1 to 2), we would remove the dimensions attributes, this looks like the easy part.
On upcast (2 to 1), we need to set the dimension attributes, so we need to get them from the image style and the image (as dimensions may vary for different images with the same style). For that, a call to Drupal's PHP seems unavoidable, so we would need to make an AJAX call.
I first thought of an AJAX callback using the image_style theme/template, which would render the image tag with the correct attributes for the given style, but this leads to much complexity: if some contrib modules or the theme would alter the rendered image tag, a correct downcast afterwards would not be that easy. So that the AJAX callback would probably simply call ImageStyle::transformDimensions().
Has this any chance to get into core? Is there a simpler way to do it? Or maybe the #368 scenario is too rare and not that problematic, compared to the complexity of the fix? Should it be a follow-up?
NB: this fix might also help solve a follow-up (#2917954: [PP-1] [drupalImage] Disable image resize handles when image style is set) if width and height would become forbidden attributes?
Comment #374
rgpublicConsidering #2822389, I'd say it's not very beneficial to have those WIDTH/HEIGHT attributes in there in the first place. I guess they should be removed by default altogether. Too much complexity for little benefit. If someone wants them (e.g. for more predictable page-loading behavior) - which would only work for non-responsive images anyway - there could be a text filter that grabs the final size of the image on output.
I still wonder, though, how the image styles are handled as long as the image is shown inside CKEditor? We'd also need image styles there, don't we? The image might be 4000x2000 after all. And the image style doesn't necessarily need to be the same, right?
In a perfect world, I guess it should be configurable which image styles map to which CKEditor image styles. Admittedly quite difficult, though. Just wanted to mention it ;-)
Comment #375
gaëlg@rgpublic (about #368 concern):
- Thank you for your quick feedback! :)
- Yes, that problem seems to only concern non-responsive images.
- Without dimension HTML attributes, UX gets very bad for non-responsive images, which display at full size in CKE. That seems like a bigger problem than #368, to me.
- Maybe we could (temporarily?) drop image style support for non-responsive images (i.e. work on the follow-up first!), as responsive images is a good practice. But that looks like a new proposition that may need to be discussed. For now, this issue is about non-responsive images, right? (as responsive support is in #2822389: Allow responsive image style to be selected in Text Editor's image dialog (necessary for structured content))
- We cannot really use the dimensions of the image file to set dimension attributes (if that's what you suggest, not sure I understood), because even if the file referenced by the src attribute was a styled image*, its dimensions could be different from the dimensions returned by ImageStyle::transformDimensions(). Example: image effect displaying a 84x84 image in a
<img width=42 height=42>tag for better rendering on Retina screens.*it's not the case apparently, and this might need to be fixed in a follow-up?
Comment #376
longwaveRan into this as this would be a useful addition to a site I am working on.
Unless #368 makes the editing experience significantly worse, I suggest that we delay that part to a followup. This issue is already nearly 7 years old and doesn't seem very far from getting this feature committed and usable on the front end, perfecting the editing experience by solving all the issues described in #368/#373-375 sounds like it might take a long time.
Comment #377
longwaveFixed the test failures and coding standards issues.
Comment #379
ravi.shankar commentedHere I tried to fix failed tests of patch #377.
Comment #381
longwaveFixed the remaining test fail following #3153009: Create "Wide" image style for standard profile
Also fixed the $modules property following #2822382: Make every $modules property protected on classes extending BrowserTestBase and KernelTestBase
Comment #382
aaronmchaleAs per result of manual testing in #296, I have queued patch in #293 for testing against 9.1.x.
Comment #383
k.skarlatos commentedWhen i apply the patch i get this on updatedb:
PHP Fatal error: Cannot use Drupal\Core\Config\Entity\ConfigEntityUpdater as ConfigEntityUpdater because the name is already in use in /var/www/clients/client8/web38/web/web/core/modules/image/image.post_update.php on line 12
core version is 8.9.2
Comment #384
dbielke1986 commentedComment #386
vsujeetkumar commentedFixing Test, Please review.
Comment #387
longwaveThanks for fixing the tests. As I've only contributed a tiny part of this patch I hope I'm OK to mark it RTBC - this issue has been open for years and it would be nice to get it fixed.
Comment #388
drou7 commentedI don't want to use patch of this issue anymore but now I have this error when I delete the patch:
Drupal\Component\Plugin\Exception\PluginNotFoundException: The "filter_image_style" plugin does not exist.
How can I delete this filter?
PS: I have the same problem as #383.
Comment #389
robotjox commentedYes, same problem on updb here.
Seems the following line from the patch clashes with something:
use Drupal\Core\Config\Entity\ConfigEntityUpdater;Commenting this out enables the database update to complete, but I have no idea if that is a problem?
EDIT: Oh, it seems - for me at least - that line was already present in image.post_update.php, so adding it via the patch creates a duplicate line. Maybe because of some previously applied patch?
Comment #390
alexpottUnfortunately there are some things that need to be addressed.
We need to add
drupalimagestyleto core/misc/cspell/dictionary.txtNeed to run
yarn run buildto rebuild this file. Some recent updates to tools result in some changes to this file.This means that we have a dependency on the allowed styles - if they are set. If an image style is deleted and it is listed in the allowed styles then we need to remove it. We need to implement \Drupal\image\Plugin\Filter\FilterImageStyle::calculateDependencies()
And then we also need to implement an onDependencyRemoval somehow (similar to \Drupal\workflows\WorkflowTypeInterface::onDependencyRemoval) and call it from \Drupal\filter\Entity\FilterFormat::onDependencyRemoval() - I wonder if there is an issue somewhere to allow plugins to have a generic reaction to onDependencyRemoval() - ahh yep there's #2579743: Config entities implementing EntityWithPluginCollectionInterface should ask the plugins to react when their dependencies are removed which looks stalled.
attribute whose value is the image style machine-name. The image file
data-entity-uuidshould be also present.');+ }
I think we could list all image styles here - so we can remove this.
attribute whose values is the image style machine-name. The following image styles can be used: @image-style-list. . The image file
data-entity-uuidshould be also present.', [+ '@image-style-list' => implode(', ', $this->getAllowedImageStyleOptions()),
+ ]);
I think we could list them all as proper list. \Drupal\filter\Plugin\Filter\FilterHtml::tips() for example builds a massive table.
I think we could use the sorting functionality to sort this by value.
I think we need to do array_values() here so that we don't end up with arrays keys and values duplicating themselves in config.
Comment #393
claudiu.cristeaAn unofficial version of #392 for Drupal 8.9.x.
Comment #394
claudiu.cristea#392 fixes all remarks from #390.
Comment #395
claudiu.cristeaThe unofficial 8.9.x version.
Comment #397
claudiu.cristeaFixing the 8.9.x tests.
Important note: The 8.9.x patch should not be reviewed, it's posted here just for sites that need an 8.9.x version. Only the 9.2.x code is for review.
Comment #398
longwaveAll review points were addressed. I do wonder if the filter tips change is out of scope, but it is a nice improvement at the same time so hopefully we can squeeze it in here - if it is accepted we should follow up and change FilterHtml to do the same thing.
Comment #399
alexpottThe
The image styles that can be used. If none are selected then all image styles can be used.UI pattern is very confusing. Has the UI been approved by the UX team?This pattern is the opposite of the entity type selector for entity reference fields. And looks pretty bad from an accessibility point of view where unticked can mean both selected or not depending on whether any of the other styles are selected.
I'm also not sure about the link to configure the allowed image styles. We don't have a link to configure the whole text format from the text format selector. This seems unnecessary UI to me.
Comment #400
alexpottThis issue has a lot of follow-ups so I've take a look at them to check that nothing has been postponed that shouldn't be. The one that concerns me is #2917954: [PP-1] [drupalImage] Disable image resize handles when image style is set. It was added to expedite this issue which is never a good sign. It would be great if the ux team could validate whether this decision is valid - I'm not sure.
The rest seem ok...
#2840462: [PP-1] [drupalImage] Restrict available image styles for uploaded images is part of the current patch and so can probably be closed as a duplicate of this issue
#2822389: Allow responsive image style to be selected in Text Editor's image dialog (necessary for structured content) feels a reasonable follow-up as it is a widening of the use-case.
#2822589: Followup: Allow image style to be selected in Text Editor - add preview also seems a reasonable follow-up. Given the size of the dialog box I imagine this is going to be very hard to implement.
#2840511: Validate file instances in Text Editor fliters & #2840513: Remove attributes from filtered inline images both seem fine as follow-ups - and probably need more discussion on the issues.
Comment #402
longwaveAddressed most of the MR feedback and #399.2. I have not addressed the Umami or standard profile default config.
For #399.1 what should we do instead? Just validate the form to ensure that at least one checkbox is checked?
Comment #403
niko- commentedupdated patch againt latest d9
Comment #404
niko- commentedfix schema issue
Comment #405
lan commentedHi,
I have added this patch to the site, the "display image styles" displays on text editor configuration, but it is not showing up on CKeditor when adding the image.
Comment #406
lan commentedHi,
I have added this patch to the site, the "display image styles" displays on text editor configuration, but it is not showing up on CKeditor when adding the image.
Comment #407
karishmaamin commentedPatch #404 works in D9.2, here is the patch that removes custom code failure error in #404
Comment #410
clayfreemanAdding patches based on the MR, though rebased on 9.4.x. The untested patch contains the full commit history from the MR, while the plain patch is used for testing only. Will need @claudiu.cristea to change the target branch to 9.4.x before the MR can be rebased.
Comment #411
mygumbo commentedWill this make it into the 9.4 release? Thanks.
Comment #415
claudiu.cristeaThis is new feature so it goes in 10.
Drupal 9.4 MR: https://git.drupalcode.org/project/drupal/-/merge_requests/2344
Drupal 10.0 MR: https://git.drupalcode.org/project/drupal/-/merge_requests/2345
Comment #416
sachbearbeiter commented10! ... hysterical laughter ...
Comment #417
lazysoundsystem commentedThis updates the 'plain' patch in #410 so it applies cleanly. (I haven't tested it further than that, yet.)
Comment #418
ravi.shankar commentedRemoved deprecated methods from the patch #417.
Comment #419
rootworkComment #420
timohuismanRerolled #410 against 9.4.x-dev because of #3290909. Removed the Drupal\Core\Config\Entity\ConfigEntityUpdater import from image.post_update.php because it was already added in #3173180.
Comment #421
rootworkComment #422
nod_Commit check failures
The last patch doesn't pass commit checks, could you make sure to run
./core/scripts/dev/commit-code-check.shbefore uploading a patch to make sure there are no issues with code formatting. see https://www.drupal.org/docs/develop/development-tools/running-core-devel...es6 files
In Drupal 10 there is no
.es6.jsfiles anymore see https://www.drupal.org/node/3305487 The changes to the *.es6.js files needs to be moved to the corresponding Drupal 10 *.js file. The changes to the generated files should be dropped as there is no code generation in Drupal 10.careful reroll
The patch can be tricky to reroll and some code might get lost in the process. When rerolling this issue please make sure all the parts of the patch are kept (new files, new tests, all the changes to the different parts of the file, changes to es6 files ported to .js files, etc.)
Thanks!
Comment #423
gaëlgAnd this patch is for CKEditor4. Drupal 10 core uses CKEditor5.
NB: I'm working on a CKE5 plugin in #3317804: Compatibility with CKEditor5 (default in D10 core).
Comment #424
nod_Oh! in that case we might need to to a whole new issue and move this one to the CKE4 contrib module.
Comment #425
jcnventuraRe-roll of #420 to Drupal 10.1. I've executed commit-code-check and there are no errors reported.
About @nod_'s comment in #24, this issue is doing a lot more than just a CKeditor plugin. There's a Drupal text filter being added that needs to stay in core. What should probably be done, is to add a CK5 plugin to this patch, and extracting the CK4 plugin code into an issue in the ckeditor module, but that plugin won't work without the text filter being added here.
Setting to needs review to see if the testbots still like this.
Comment #426
jcnventuraBetween #420 and #425, one of the rejected patches was the change to core/misc/cspell/dictionary.txt. Seems that it is still needed. Adding that back.
Comment #427
jcnventuraA typo slipped by in core/modules/image/image.post_update.php, and of course, this patch was using now-deprecated functions, so those have now been updated.
This is probably as far as this can go. Next step is to replace the CK4 plugin with a CK5-compliant version.
Comment #428
jcnventuraAnd a re-roll after #3247795: Add text filter plugin to support <img loading="lazy"> and remove it from editor_file_reference
Comment #429
digitalfrontiersmediaThe patch that was working for 9.4.x (#420) no longer applies and the new work (#425-#428) is all for 10.1.x and doesn't apply to 9.5.x either. Removing the patch after having used it and trying to run 9.5.x to see what happens results in:
So I'm stuck reverting back to 9.4.9 with the patch and can't upgrade. Waiting until June of 2023 for 10.1 to be released seems a bit much. And there's a lot in this patch to try to figure out for someone stepping into it new.
Has anyone already familiar with the code ported this patch for 9.5.x?
Comment #431
mstrelan commentedUpdating title. There are many approaches to creating structured content and I'm not sure this warrants the word "necessary" any more. Certainly would be nice to have though!
Comment #432
gaurav-mathur commentedComment #433
gaurav-mathur commentedApplied patch #428 successfully on drupal version 10.1.x and working fine.
Comment #434
twodRe-rolled #420 for 9.5.x. The interdiff got huge so just posting the summary here of what didn't apply:
core/profiles/standard/config/install/filter.format.basic_html.yml
core/profiles/demo_umami/config/install/filter.format.basic_html.yml
Other tags had been added/removed from the allowed_html list, just needed to add the data-image-style attribute from the patch back in.
core/lib/Drupal/Core/Entity/EntityDisplayBase.php
The use statement for the DependencyRemovalTrait trait could not be automatically merged in due to context changes.
Comment #435
nitin shrivastava commentedtry to fix #434
Comment #436
digitalfrontiersmedia@TwoD -- Thank you!
I confirm the patch in #434 applies on 9.5.0 (even if it appears to fail some of Drupal's automated tests).
Comment #437
prudloff commentedHere is a reroll for Drupal 10.0.
Comment #438
needs-review-queue-bot commentedThe Needs Review Queue Bot tested this issue. It either no longer applies to Drupal core, or fails the Drupal core commit checks. Therefore, this issue status is now "Needs work".
Apart from a re-roll or rebase, this issue may need more work to address feedback in the issue or MR comments. To progress an issue, incorporate this feedback as part of the process of updating the issue. This helps other contributors to know what is outstanding.
Consult the Drupal Contributor Guide to find step-by-step guides for working with issues.
Comment #440
super_romeo commentedPatch #428 can't not be applied anymore on D10.1.x.
Is is still needed?
Comment #441
alorencUpdated drupal-2061377-437.patch, added fixes for the following issues:
------ ---------------------------------------------------------------------
Line core/modules/image/image.module
------ ---------------------------------------------------------------------
561 Function file_url_transform_relative not found.
💡 Learn more at https://phpstan.org/user-guide/discovering-symbols
------ ---------------------------------------------------------------------
------ ---------------------------------------------------------------------
Line core/modules/image/tests/src/Kernel/EditorImageStyleDialogTest.php
------ ---------------------------------------------------------------------
102 Function file_save_data not found.
💡 Learn more at https://phpstan.org/user-guide/discovering-symbols
106 Function file_url_transform_relative not found.
💡 Learn more at https://phpstan.org/user-guide/discovering-symbols
------ ---------------------------------------------------------------------
Comment #442
i-trokhanenkoHere is a reroll of #441 for Drupal 10.1.1
Comment #443
chikePatch #442 applied on Drupal 10.1.1 but no image styles are showing up in CKEditor. I did turn on 'Display image styles' for the editor and selected some image styles in the configuration but using the 'Insert image' button offers no image styles.
Perhaps this feature is not yet targeted at CKEditor 5 as screenshot above is CKEditor 4.
Comment #444
smustgrave commentedCC failure
Also such a feature will need a change record.
Comment #445
ruslan piskarovIs it for CKEditor 4 only?
Comment #446
smustgrave commentedCk4 is gone from core so will only be CK5.
Comment #447
gaëlgYep, as far as I know, it's discussed in comments #423 to #425 above but has not yet been addressed.
The current patches are for CKE4 and should rather be in a CK4 contrib module issue, probably depending on this one or restricted to Drupal 8/9. And this issue should be focused on core/CKE5, in which case it should be considered as having no patch for now (I just unchecked "display" on the available patches).
If you need this feature on CKE5, the best available option for now is the Inline responsive images contrib module with a patch from #3317804: Compatibility with CKEditor5 (default in D10 core).
Comment #448
cobadger commentedRevised 10.1 patch forthcoming.
Comment #449
cobadger commentedRe-rolled patch for 10.1.x.
Comment #450
smustgrave commentedCC failure.
Also appears there is no test coverage
Comment #451
gaëlgPlease put CKE4 patches in the newly created #3392556: Allow image style to be selected in Text Editor's image dialog (CKE4). Patches here should contain a CKE5 plugin.
Comment #452
vsujeetkumar commentedMissing Trait file in #449, Added and fixed the CCF issues. Keeps as in 'Needs Work' to address #450.
Comment #453
gaëlg@vsujeetkumar: Thank you for your work, but as said above, please put this patch into #3392556 contrib issue instead. There is no chance for it to be accepted for core as it targets CKE4.
Comment #454
flyke commented#388 and #429: In case like me you are updating your Drupal and get stuck because you keep having an error like this:
Then the solution is to create a dummy filter with that ID. So I created a custom module containing mymodule/src/Plugin/Filter/FilterImageStyle.php with this content:
Now after
drush cr, you should be able to continue your work and make sure this filter is not used anywhere. For me I first exported all my config withdrush cex -y. Then I searched my config/sync folder for 'filter_image_style' and removed the references to that. Then I imported updated config withdrush cim -y.Comment #455
claudiu.cristeaThis is #422 to work with Drupal 10.2 for whom might be interested
Comment #456
martijn de witDrupal 10.2 is released
Comment #457
bramdriesenRe-queued the tests for the 11.x branch.
Comment #458
bramdriesenSo we have issues with Cspell, PHPStan, PHPCS and I also think there is an issue with one of the JS files.
Probably also best to re-roll this patch over to a MR so we can benefit from GitLab pipelines as well.
Comment #459
bramdriesen*edit* somehow comment got posted twice
Comment #460
gaëlg@flyke @claudiu.cristea @Martijn de Wit @BramDriesen: please see #447 and #451.
Comment #461
rishi.kulshreshthaI came across this issue while working on D10 upgrade for one of my sites. Please refer to the attached patch for anyone looking for a backport patch.
PS: Thanks to @TwoD for submitting the initial patch!
Comment #462
rishi.kulshreshthaPlease ignore the previous patch. The attached patch is the correct one, this includes the missing file
core/lib/Drupal/Core/Entity/DependencyRemovalTrait.php.Comment #463
wim leersWow, blast from the past. I just stumbled upon this issue after not having seen it for a very long time (and after having started it … over a decade ago 👴). Let's get this done at last!
#3306584: [11.x] Remove EditorLinkDialog, EditorImageDialog and EditorMediaDialog in Drupal 11 removed
EditorImageDialog. So this should now become a CKEditor 5-specific issue. And the current patch already does that! 👍Adjusting issue title + component.
The issue summary's screenshots show CKEditor 4. They need to be updated.
Review
FilterFormatorFilterBase. As long as that's the case, this issue will never land. Can we please extract those changes into blocking issues? 🙏*.es6.jsfile in there. We haven't been using those in at least a year, so the current patch could never land as-is in Drupal 10. And … this is still targeting CKEditor 4? 😅 CKEditor 4 is EOL, it's not part of Drupal core anymore. Fortunately, for CKEditor 5, there's reusable infrastructure for this kind of thing already: theDrupalElementStylefunctionality in thedrupalMediaplugin — there's even a nice blog post about it that should make it much easier to get started.Comment #464
gaëlgNote that there is a contrib module which provides this kind of feature, even for CKE5. In case it can help.
https://www.drupal.org/project/inline_responsive_images
Comment #465
aubjr_drupal commented+1 for this feature getting in. I just ran into this need, and it seems like a no-brainer addition in the spirit of Starshot.
Comment #466
gcalex5 commentedRe-roll of #455 for 10.3.x
Comment #467
jannakha commentedpatch #466 applies to D10.3, but selected image styles are not visible in CKEditor 5 while adding/editing image:
Config works as expected:

Selected image styles are not available in CKEditor5:

Comment #468
hotfingers commentedRegarding patch #462 after using it I can't access /admin/reports/status anymore, with no errors being shown at /admin/reports/dblog.
Now I'm trying to remove it, as I went with the media library with view modes alternative, but then I get:
[error] Drupal\Component\Plugin\Exception\PluginNotFoundException: The "filter_image_style" plugin does not exist.
Like in #192, #388 and #429.
I did some digging and as I understand, it seems like the filter is still present inside the text format entry of the DB, even after removing the patch.
You can check with:
SELECT * FROM config WHERE data LIKE '%filter_image_style%';
That it's still inside the BLOB of the text format.
How can I safely remove this patch and the DB entry? I don't want to mess with the DB directly, for obvious reasons.
Thanks to anyone that can help.
Comment #469
rgpublic@hotfingers: Just a wild guess, but I think you'd have to reenable the patch again, so that you have that filter plugin available again. This should bring everything back to life. Then, go to all your filter formats and make sure that you have disabled the plugin first and save these settings. None of your filter formats should have that plugin enabled. Only then I guess can you safely remove the patch again.
Comment #470
j_s commentedAlso tested #466 and have the same issue with it as #467 on Drupal 10.3.6. I moved around the filter order and cleared cache with no success.
Similar to #468, I tried to remove the patch and admin pages would whitescreen with the error. I disabled the plugin in my text filter before trying to remove the patch. I had to reload from backup to recover the test site.
Comment #471
sachbearbeiter commentedIs there any hope of finding this must-have feature in a release? I have no idea why Drupal is built on a modern PHP codebase and it is still not possible to provide basic UI functionalities for the editorial team?
Comment #473
heddnThere's a lot of re-work needed to make this work w/ CK5 and D11. https://www.drupal.org/node/3291493 deprecated the image dialog forms. I'm going to leave this at NW for now. But I started some of the rebase work in https://git.drupalcode.org/project/drupal/-/merge_requests/10767. It is a pure rebase. From here on, we'll need to figure out how to make this work with CK5. I'm not taking that on at the moment.
Comment #479
prudloff commented