I think there are already lots of issues and documentation covering the fact that the Xss filter will ignore on* and style attributes. Since that is the case, I think the "Alignment" under "Image Properties" (after double clicking an image within a text edit field) should be re-worked. Right now, if I select the "Right" blip in the Alignment section of Image Properties, for example, the result is to add style="float:right"
to the image tag's HTML. Because of this, the alignment options only work if the "Text Format" is set to "Full HTML", or if the "Limit allowed HTML tags and correct faulty HTML" box is unchecked when using an alternate Text Format.
To resolve the problem, couldn't the "Alignment" options instead add a simple css class to the image HTML (example: .float-right), and Drupal core CSS could handle floating these classes appropriately (example: .float-right {float: right;})? This would allow the alignment options to work for all Text Formats, assuming the site administrator has enabled <img class>
in the "Allowed HTML tags" field if using "Limit allowed HTML tags and correct faulty HTML".
I don't see how this solution would go against any Drupal policies. But, if for whatever reason this is unacceptable, and there is no acceptable solution, I think that at the very least the Alignment settings shouldn't be shown in "Image Properties" when the "Text format" is using "Limit allowed HTML tags and correct faulty HTML", as they are simply misleading and confusing in this context currently.
Comment | File | Size | Author |
---|---|---|---|
#35 | imce_module_is_not-2798959-35.patch | 1.23 KB | dylf |
#27 | with_image_upload_disabled.png | 21.92 KB | xeM8VfDh |
#26 | imce_image_properties.png | 15.23 KB | xeM8VfDh |
#26 | imce_button.png | 28.47 KB | xeM8VfDh |
#26 | drupal_image_properties.png | 20.37 KB | xeM8VfDh |
Comments
Comment #2
xeM8VfDh CreditAttribution: xeM8VfDh commentedComment #3
Wim LeersHUH!???!!
Can you please record a video showing this? What I see, is
class="align-right"
being added.Also, how are you even seeing
? That's something that lives in CKEditor's native image dialog, which Drupal does not use. That'd explain why you're seeing floats; you should be seeing Drupal's own image dialog for CKEditor, not CKEditor's default one.Very curious to see how this could have happened!
Comment #4
xeM8VfDh CreditAttribution: xeM8VfDh commentedOkay. This is very weird. Sometimes when using the alignment options it applies a style float to the image html, and other times, it applies a class to the parent
<p>
tag. I have done lots of testing, and the best that I can determine is that, with Full HTML, aligning left and aligning right applies the style attribute, while aligning center applies the class to the parent<p>
. When using a Text Format that implements the HTML Filter (Basic HTML in my case), neither the left, center, or right alignments in Image Properties work, leading me to believe that all of them are trying to add a style attribute. If I create some text and use the center align CKEDITOR button, it properly aligns the text in the center. If I click the image and click the center align button (instead of using the Image Properties alignment), it still does not center the image. Well, sometimes it doesn't, but sometimes it does (see second video). It seems that I need to highlight the image and click right align for it to work. If I just have the cursor right before/after the image and click the right align button, it works in the editor window, but upon saving, it doesn't.It seems to me that there is some method by which style attributes are applied
and other methods by which it properly adds a class to the parent
<p>
I don't know. This is a weird one.
Here's what the videos show:
1_image_properties_alignment.ogv
2_alignment_buttons.ogv
As for why "Image Properties" is even showing in my setup, I don't know. I have Imce File Manager installed, and a few other modules. Not sure if any of them may be responsible.
FOR WHAT ITS WORTH: All of the above aside, assuming we resolved the wonkiness, I do think the Image Properties alignment should be adding float classes, not "text-align" classes. I think this because, if one wants "text-align", they can simply use the alignment buttons. The Image Properties alignment options should offer float options so that one can properly position the image relative to it's context, one of the more popular application being wrapping text around an image, as shown here: https://www.youtube.com/watch?v=xFVfX2sevNI
Comment #5
Wim LeersThanks for that video. The first one shows me after 20 seconds that you are NOT using the Drupal CKEditor image plugin. You're using something custom. What module did you install to get that?
Comment #6
xeM8VfDh CreditAttribution: xeM8VfDh commentedWhere would I go in my system to check which image plugin I am using instead of Drupal CKEditor? My first guess would be that it is provided by IMCE File Manager....
MODULE: https://www.drupal.org/project/imce
D7 DEMO: http://ufku.com/drupal/imce/demo
Comment #7
Wim LeersRight, that means that that is the problem. We saw a similar problem with IMCE at #2666596: Link cannot be placed around an image without the image button's presence, also caused by it not building upon the infrastructure that D8 provides.
So, retitling and moving to the IMCE issue queue.
Comment #8
xeM8VfDh CreditAttribution: xeM8VfDh commentedThanks very much @Wim Leers, you've been super helpful, and I really appreciate the quick responses!
Comment #9
Wim LeersYou're welcome :)
Comment #11
ufku CreditAttribution: ufku commentedAdded drupalimage as a requirement for imce plugin.
Comment #12
xeM8VfDh CreditAttribution: xeM8VfDh commentedthanks @ufku. Just to clarify, I see DrupalImage.php here: https://api.drupal.org/api/drupal/core%21modules%21ckeditor%21src%21Plug...
I see this file on my filesystem. Is it something we users enable somehow, or is it and internal include the IMCE must utilize to resolve the issue at hand?
Thanks again for the quick help!
Comment #13
Wim LeersThis maybe makes things better, but it's certainly not a complete solution. The real problem is that http://cgit.drupalcode.org/imce/tree/js/plugins/ckeditor/imce.ckeditor.j... does not extend the
DrupalImage
CKEditor plugin.Comment #14
xeM8VfDh CreditAttribution: xeM8VfDh commentedthanks for the feedback @Wim Leers
Comment #15
Wim LeersYou're welcome!
Comment #16
xeM8VfDh CreditAttribution: xeM8VfDh commented@Wim Leers, I should have asked in my last comment... should I switch the status from fixed to Needs Work (or Active) since this doesn't look sufficient to you?
Comment #17
Wim LeersThat depends: did this commit actually address the problem described in the issue summary? Then fine, let's keep this marked as fixed, and open a separate issue.
But if this did not actually fix the problem, then this probably needs to go back to active/NW, and the commit then needs to be reverted.
Comment #18
xeM8VfDh CreditAttribution: xeM8VfDh commented@Wim Leers, I haven't personally tested the patch
Comment #19
Wim LeersWell then… how can this be marked
?Comment #20
xeM8VfDh CreditAttribution: xeM8VfDh commented@Wim Leers, right you are, thanks for changing. If I can set up an environment to test it I will and report back.
Comment #21
Wim LeersYou're handling this in an exemplary way :) Looking forward to see IMCE be nicely integrated with Drupal 8's text editor! :)
Comment #22
xeM8VfDh CreditAttribution: xeM8VfDh commented@Wim Leers, since @ufku's fix was a commit, not a patch posted to this issues, am I correct in assuming that if I simply test against the current Dev branch of IMCE, that will suffice?
Comment #23
xeM8VfDh CreditAttribution: xeM8VfDh commented@Wim Leers and @ufku, the proposed change does not seem to work. Additionally, it appears to break other Image Properties functionality. I created a fresh D8 site, added an image to a page using the default image button, and the alignment options worked. I then installed the 8.x-1.3 release of IMCE to confirm that the problem reported by this issue still existed on a fresh site install (to rule out the possibility of my current site's environment playing a role in the problem). The problem still existed.
I then disabled the 8.x-1.3 release and removed the imce folder from the modules directory on my filesystem. I then installed the 8.x-1.x-dev branch tar (2016-Oct-02), replaced the regular Image button in the Text Formatter with the IMCE provided "Insert image using IMCE File Manager" button, and the behavior is altogether different. Now when I right/double click the image added via the "Insert image using IMCE File Manager" button, then selected "Image Properties", the only options are to to browse for a new file and add/edit the "Alternative Text" value. So the change pushed to the dev branch altogether removed the options to edit width, height, alignment, and caption.
The change may be in the right direction, but it currently doesn't appear to be implemented correctly, given my testing experience. IMO, the commit should be rolled back or the above described issues should be resolved before tagging a new release, since it breaks more functionality than does the original issue.
@ufku, did you test this before committing and experience different behavior?
Comment #24
ufku CreditAttribution: ufku commentedThose who want proper Image support can use the core Image button without the Upload option. You'll see IMCE integrated into the URL field.
Comment #25
xeM8VfDh CreditAttribution: xeM8VfDh commentedComment #26
xeM8VfDh CreditAttribution: xeM8VfDh commentedApologies @ufku, but there must be some sort of communication gap here.For starters, can we abide by the best practice of not closing the issue until the solution has been tested and confirmed as working? That seems reasonable to me.It sounds to me like you are suggesting: "If users care about image alignment, they should use the standard Drupal provided 'image' button instead of the IMCE provided 'Insert images using IMCE File Manager' button".If that is not what you are suggesting, I would greatly appreciate you clarifying your statement. If this IS what you are suggesting, its simply a bad suggestion. While the standard image button's alignment functionality does work, this button does not allow users to browse/select files that are already on the server instead of uploading a new file. This is the entire reason people download IMCE. So, an IMCE dev suggesting users appeal to the standard Drupal image button instead of the IMCE image button simply does. not. compute. The other reason that this suggestion is bad is because it completely ignores the fact that your most recent commit is an inarguable downgrade of the IMCE button's functionality.You said: "use the core Image button without the Upload option. You'll see IMCE integrated into the URL field."What does this mean? Please provide further detail and/or screen shots. My testing indicates that there is no url field when clicking the standard Drupal image button, and that you haven't affected the standard Drupal image button at all, but rather broken the IMCE image button further.I've attached screen shot to compare the results of using standard Drupal Image button/properties and IMCE image button/properties.See comment below
Comment #27
xeM8VfDh CreditAttribution: xeM8VfDh commented@ufku, I gathered, from your comment #10 comment on the other ticket (for those out there not following both issues) that the Text Format in question must have " Enable image uploads" unchecked. Once that is taken care of, the url/browse functionality appears on the regular button.
See attachment.
Comment #28
xeM8VfDh CreditAttribution: xeM8VfDh commentedUnfortunately, there is still a problem.
SCENARIO 1: IMCE is not installed. I add an image to a page using the drupal core image button. I can align the image, save the page, and the alignment is enforced. I can then edit the page, and the alignment is preserved. I can right/rouble click the image and change the alignment if I want to. No problems here.
SCENARIO 2: IMCE is installed and enabled. The Test Format in question has "Enable Image Uploads" unchecked. I add an image to a page using the standard drupal image button, then use the new IMCE integration to browse for a file, the image is inserted into the page, then I right/double click the image to get to Image Properties and align it accordingly. The alignment is enforced on the page. I then edit the page, and the alignment is not enforced in the WYSIWYG editor. Furthermore, now when I right/double click the image, there is no "Image Properties" option, which means I cannot adjust alignment. If I save the page, the alignment is preserved, but if I want to adjust it, I need to remove the image, add it back, and adjust it there when adding it.
Since everything works as expected without IMCE installed/enabled, but does not work as expected when IMCE is installed/enabled, my instinct is that IMCE is not implementing the core drupal image functionality properly. This may be an incorrect interpretation. What do you think @ufku and @Wim Leers?
Comment #29
Corregidor CreditAttribution: Corregidor commentedAny updates here? Adding links to images is currently broken, as is Drupal's file cleanup, for images added with IMCE. Is this the recommended module for managing images in Drupal 8's CKEditor?
Comment #30
xeM8VfDh CreditAttribution: xeM8VfDh commented@Corregidor, unfortunately I don't have an update, and am interested myself. Maybe @ufku and/or @Wim Leers have more info
Comment #31
FreMun CreditAttribution: FreMun commentedWe have the same problem as @xeM8VfDh (Scenario 2).
What I noticed is, that if I push on Source Code, the data-entity-uuid and data-entity-type are both empty. If I fill them with proper data: data-entity-type="file" and data-entity-uuid="aabb9abe-1e5b-4c17-9608-6347ee0964f8"(this is the real uuid of my node) everything works as expected.
I don't know how to resolve this, but I hope that the people who works on this project do :-)
Comment #32
xeM8VfDh CreditAttribution: xeM8VfDh commentedthanks @FreMun, that's really helpful info. Hopefully @ufku will know what to do to get the proper data in those html properties and resolve this issue.
Comment #33
FreMun CreditAttribution: FreMun commentedI found this line of code in core/modules/editor/src/Form/. I suppose this has something to do with it?
$existing_file = isset($image_element['data-entity-uuid']) ? \Drupal::entityManager()->loadEntityByUuid('file', $image_element['data-entity-uuid']) : NULL;
Comment #34
xeM8VfDh CreditAttribution: xeM8VfDh commentedGreat find! Paging @ufku
Comment #35
dylf CreditAttribution: dylf commentedThe issue is the fid in the form_state is not being set on upload, causing the data-entity-uuid & data-entity-type to not be set in the submit handler. Added a little validation function to the image dialog form to set the fid based on the source, not sure if its the cleanest solution but it works!
Comment #36
xeM8VfDh CreditAttribution: xeM8VfDh commentedthanks @dylanf! Can a commiter (@ufku ?) review and merge the patch?
Comment #37
Hubbs CreditAttribution: Hubbs commentedPatch didn't work for me. Applied to 2 different composer based sites. I tried both 1.4 and 1.x-dev versions on IMCE. I even tried to manually apply the patch instead of using composer. Everything else on the site was using latest versions.
A co-worker did get it to work successfully on a different D8 site with the exact same settings, the only difference being his wasn't using composer and so he manually installed the latest dev version of IMCE and had applied the patch manually. I'm not sure what would be different.
Comment #38
xeM8VfDh CreditAttribution: xeM8VfDh commentedhuh... that's odd. I'll chime in if I get a chance to test the patch. Thanks for the feedback @Hubbs
Comment #39
Hubbs CreditAttribution: Hubbs commentedFollowing up on my previous comment, my co-worker applied this patch successfully on a composer based site. So I guess the issues I'm having are conflicting on my end. If I find out why and it's applicable here, I'll post another follow-up. Otherwise, I think this patch is probably good to go.
Comment #40
xeM8VfDh CreditAttribution: xeM8VfDh commentedGreat, thanks @Hubbs. I've been swamped, with no time to test myself. Will report back if I do.
Comment #41
ufku CreditAttribution: ufku commentedSee #2771837: drupalimage CKEditor plugin should not require data-entity-uuid and data-entity-type when image upload is disabled
Comment #42
farse CreditAttribution: farse at Zoocha commentedmy problem is regarding Scenario 2 in https://www.drupal.org/node/2798959#comment-11727617
I tried the patch at https://www.drupal.org/node/2798959#comment-11882065 and it seems only to work for some files but not others. Not completely sure why, maybe it could be the manner in which the images have been uploaded to the site?
I just check the above issue and the comment at https://www.drupal.org/node/2771837#comment-11820119 states that "Also, it doesn't work for images added by any other module or ckeditor plugin which does not set the attributes (IMCE for instance)." But with that said, I tried the patch in there and it now works..
But is it really a duplicate?
Comment #43
xeM8VfDh CreditAttribution: xeM8VfDh commentedThanks for the info @farse, hopefully the issue this one was closed in reference to (duplicate) will address the problem: https://www.drupal.org/node/2771837
I am still experiencing it too.