-
Notifications
You must be signed in to change notification settings - Fork 40
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
CKEditor: allow uploading an image. #1088
Comments
I filed a PR at backdrop/backdrop#1015 that adds all this functionality. A lot of the crucial code was already committed a in the first CKEditor PR, but this completes it. This patch goes a bit further than the original Drupal patch, which only allowed file uploading or URLs, but not both at the same time. Enabling uploading would disable raw URLs, which may be desirable for some sites but probably not the most common use-case. Screenshot of the upload/URL toggle: This needs a few additional tests for the server-side registering of associating content with files based on the |
Works great. Few issues:
the source button reveals this code in the editor:
Granted for both 1 and 2 above, the p tags and content disappear on closing the source view.
|
Yeah the handling of blank/removed images is not good. I'll work to make that remove the
Yeah I'm not sure if that problem can be solved (easily). I think that's CKEditor behaviour to remove itself on form submit. A separate issue for us in any case.
I thought I had covered this situation. When toggling to the upload, the value from the URL should be getting removed via JS (and restored if you toggle back to it). I'll give it another go. Thanks for testing! |
Updated the PR to fix these problems. Blanking out an image src string or clicking the "Remove" button now removes the image from the editor. I couldn't reproduce a problem with using src and an upload at the same time. It seems that using both will use the src string if the "Image URL" is selected, or the uploaded file if the "Image upload" option is selected. Tests still needed, I'll work on those next. |
p.s.:
Already ported! https://github.com/backdrop-contrib/filefield_sources |
Nice! I'll have to give that a shot in combination with this to see what the overall effect is. I updated the PR with a second commit that adds some polish. Enabling and disabling buttons now hides/shows related settings. e.g. disabling the "Image" button will hide all image uploading settings. Same for the "Styles" button and associated textarea. |
Haven't actually tested this yet, but here's a couple of comments from what I can see from the screenshots: The textfield for Image URL will allow for both local paths as well as full external URLs (copy-paste image link like say youtube video URLs), right? If so, then shouldn't we call these something like "Upload image" and "Link to image" instead? The way "Add a caption" works still bothers me (I think I've mentioned this before bt not sure if I filed an issue for it). Why not have a textfield for a caption show directly on the dialog there once the checkbox is ticked? |
👍
Very yes, but not a 1.2 blocker though. |
Turns I have already filed an issue for the caption checkbox thing: point 2 in #1093 |
It is really good to have image upload working - thanks. But I am finding that align center is causing a failure. Perhaps this is just my trial installation? What should it be achieving in the html? |
In the HTML it should be creating a Tests have been in place for a week now and it sounds like the testing on this functionality has been positive. Unless there's anything around this issue, I think we may be ready for the commit on this functionality. |
I uploaded from core in backdrop-1088-editor-upload to replace core in a previous version and everything seems to work fine, including the align left and align radio buttons, but align center causes a freeze, the image disappears and I am unable to view the source code. |
Great, thanks for the report Graham. I bet there's a JS error on the page. I'll see if I can reproduce. |
I've fixed this issue in the latest changes to the PR. backdrop/backdrop#1015 There were some other issues relating to removing an image's src within the dialog while a caption was present. The whole thing wasn't getting cleaned up properly. |
It works fine now. Great job 👍 |
Super, let's merge and improve further if needed. |
Merged in backdrop/backdrop#1015. Exciting times! |
Oh dear! Tried editing a block but could not upload an image - no response from 'save'. Also, suppose I want to insert an image that I have already uploaded? Please can we have a browse server without upload, if you get what I mean? |
I'll look into that problem here.
Yeah, that would be useful functionality. Short-term, we could make FileField Sources do this (as it just extends the "managed_file" element, which this uses). Long-term, I think we'll want to make a more comprehensive image/media dialog similar to what WordPress has. Reselecting an existing file isn't a trivial problem, as the way you would want to select an image (e.g. recently uploaded by user, recently uploaded by field, tags, filenames, etc.) can be challenging. |
This should be a view ... |
I have just been talking a new user though the process of adding an image to a page and notice problems with resizing by changing the width and height properties* compared to using IMCE and the CKEditor config module, (a) the width and height do not now appear until after saving the upload, and (b) there is no option to lock the ratio of width to height. *perhaps this is a lazy practice, but it can be very useful |
Yep, this would also be a great thing to add. For now, if exact heights are necessary, you can resize the image with the drag handle in the editor.
Yeah agreed. |
I hadn't realised this - it is a great feature - thanks. |
My previous comment
I have been checking again and this only happens if editing a layout, then configuring a block and trying to edit the content when the edit window appears. So not really a significant problem because rather an exceptional situation. |
Ah, yes confirmed. It looks like this is an issue because the image dialog closes the layout block-edit dialog. Then when the save button is clicked on the image dialog, the CKEditor instance is no longer on the page. Nested dialogs are tricky business! We may be able to fix this by having the image dialog open in a modal with a different ID. |
I added a new issue for this at #1125 and added to the meta. I also added a few placeholders in the meta. If we come up with more ideas to expand editor functionality, let's add them there: #1087 |
Right now we have the ability to insert an image into a WYSIWYG editor through a modal dialog that is provided by Backdrop. However this modal right now only provides the basics: URL, height/width, and alt attributes. There is very little point in making a dialog that does a server-side request unless we make use of the the server-side abilities that Backdrop provides us. In this case, I'm referring to allowing a user to upload an image in the image modal dialog.
Because the modal dialog is server-side, it means that we can use a #type = 'managed_file' element in the modal to handle file uploads. After the initial problem of uploading a file is handled, we may extend this element (similar to the way FileField Sources does) to provide other ways to select a file, such as using Views to select recent uploads, or to actually transfer images from remote URLs, or to paste from the clipboard, or other ways of managing files.
Drupal issue: https://www.drupal.org/node/1932652
The text was updated successfully, but these errors were encountered: