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
[New Feature] tinyMCE drag and drop images #7435
Conversation
Cool idea 👍 If that doesn't work then I would suggest to use com_ajax and do the upload part as a AJAX plugin event in the editor plugin itself. This way the code for tiny isn't spread all over the place but contained all in the plugin. 😄 |
Didn't the latest version of tiny that you just did a PR for support this
internally?
|
// } | ||
|
||
JFactory::getDocument()->setMimeEncoding( 'application/json' ); | ||
JResponse::setHeader('Content-Disposition','attachment;filename="progress-report-results.json"'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Set this directly to the application please, JResponse
is deprecated.
@Bakual i think I need to talk to @Buddhima and try to get one upload controller that fits all requests. The problem is that new media is not yet production ready! @brianteeman They introduced a new Upload API but that works with a button next to the field source in the image pop up. try it in their at tiny |
Not just the new upload and seriously cool inline editing here
http://blog.moxiecode.com/2015/06/25/tinymce-4-2-with-image-tools/ but the
release notes (sorry can't find the link right now) talk about drag and drop
|
// console.log(e); | ||
// console.log(e.dataTransfer.files); | ||
// console.log('the content '+ed.getContent()); | ||
// alert('dragdrop' + e.dataTransfer.files); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we make sure all the debug code is pulled out before merging?
@brianteeman I think this PR is adding the code needed to turn it on and make the feature work server side (something's gotta process the images). |
@dgt41 👍 very cool! .. here is link for Tiny upload http://www.tinymce.com/wiki.php/Configuration:images_upload_url I also think that |
Where should you put the controller part?Regarding the controller part, I'd say that it's perfectly acceptable leaving it in com_media. It is generic code which can be reused by other editors or extensions which want to implement asynchronous uploads. It can even be used by com_media itself to implement d'n'd uploads (hint!). Implementation of the controllerDo you need to call the files array tinyFiles or can we use a more generic name, e.g. uploadedMediaFiles? Do we really have to go through $_SERVER['CONTENT_LENGTH']? The PHP files arrays do give you the size of uploaded media. Do take a look at the existing helper method JHelperMedia::canUpload. Use it instead of custom code in lines 70:97. Centralised code can be kept secure more easily. Also, is there a compelling reason for using the code in lines 131:146 instead of JFile::upload? The latter is much better because it allows us to centrally control the security model for uploads. Whenever possible go through the existing helper methods instead of inventing new ways. It's easier for managing the system security. |
Fully agree with the controller being in com_media when it's generic. |
OK, fair enough. Having a single JSON endpoint sounds like a good idea. |
@Bakual @nikosdion we still need the controller to return the relative path and the file name of the file uploaded! Which is not available right now, right? |
I think it should be possible to adjust/extend the existing controller to return that. You can either add the additional information to the existing JSON response or in worst case add a URL parameter (eg &version=2) which acts as toggle for the response, keeping old behavior for B/C and returning new version of response if parameter is present. |
( ! ) Fatal error: Can't use method return value in write context in ROOT/plugins/editors/tinymce/tinymce.php on line 1003 I had patched with 4.2.1 and then this one. |
@infograf768 sorry about that JM, latest commit should fix that |
hmm. Patched with #7423, then patched with this. Result is negative: I can't see the new icon in the image popup and drag and drop does not work here. Maybe I missed something? |
I also have |
@infograf768 this PR doesn’t require #7423, please try it with the earlier version 4.1.6 (?) |
You mean it does not require the new imagetools plugin? I am confused. |
drag and drop is not part of the image tools, actually image tools are a bunch of plugins for client side image editing plus some generic upload code. So yes the drag and drop doesn’t really require the images tools |
|
||
if (!MediaHelper::canUpload($file, $err)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
MediaHelper::canUpload() is deprecated and also for some reason break the upload
@mbabker thanks Mike. I also made that function static cause it was giving a strict error |
The class is designed to be all OOP without statics, so change it to this please: $mediaHelper = new JHelperMedia;
if (!$mediaHelper->canUpload($file, 'com_media'))
...
` |
'message' => JText::sprintf('COM_MEDIA_UPLOAD_COMPLETE', $returnUrl), | ||
'error' => JText::sprintf('COM_MEDIA_UPLOAD_COMPLETE', $returnUrl), | ||
'location' => $returnUrl | ||
); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@n9iels this simple change will make the directories look nice even for PCs, can you check it?
'location' => str_replace('\','/', $returnUrl)
This PR has received new commits. CC: @hdwebpros, @jessicadunbar, @jwaisner, @n9iels, @nikosdion, @peterlose This comment was created with the J!Tracker Application at issues.joomla.org/joomla-cms/7435. |
and remove the restriction on the server side Also replace windows paths backslashes with forwardslashes
Hi there :)
|
I have tested this item ✅ successfully on 30dde3e This comment was created with the J!Tracker Application at issues.joomla.org/joomla-cms/7435. |
If this is the current behaviour I wouldn't change it here and call it out-of-scope and should be dealt with in another PR. Keep up the good work guys 💯 |
This PR has received new commits. CC: @hdwebpros, @jessicadunbar, @jwaisner, @n9iels, @nikosdion, @peterlose This comment was created with the J!Tracker Application at issues.joomla.org/joomla-cms/7435. |
Just removed the green color, now the theme color of the toolbar will be used. So default will be light grey (same as twitter dropbox area 😃 ) |
I have tested this item ✅ successfully on 3bb31c8 This comment was created with the J!Tracker Application at issues.joomla.org/joomla-cms/7435. |
Looks better 👍 |
Thanks for the comments @dgt41 - the grey color is better i think because it does not make the user feel that the system will accept all the images. There is an error message for duplicate file names, one for too large file size, but not at a wrong file type? Regarding the umlauts i´d like to open a new issue because thats something really annoying in german when the umlauts are eliminated from the name @roland-d :-) Can it be set this to change the "paste" position meanwhile the drag and drop process? Now i have to set the marker on the place where the image should be and then drag it anywhere. Last but not least: it´s funny that after so much years of joomla i just realized that there are plugin parameters for tinymce :-) I´d rather search them in the "Global Configuration" and also expect some Permission Parameter Setting for the Editor - thats surely also another topic... |
@designbengel starting from the last comment: there is a PR that will make tinyMCE ACL aware and is planned for 3.5 as well #8147 |
:-) Great - one more suggestion for v2 - Here in github you have a "uploading your files..." text next to the progress icon. |
@designbengel Can umlauts be used in filenames? They became part of a URL, I don't know if that is a problem. I understand it is an issue and if it can be improved we should but not in this PR though. Can you share your final test results again? If all is OK, we have 2 successful commits and we can commit this gem. |
@roland-d In theory any UTF-8 character can be used in a URL and supported by all modern browsers and servers. However, if you have any visitors still using IE7 or earlier (don't get me started...) they won't be able to access them. Some servers with questionable localisation settings may also mangle the names. So by necessity we transliterate all URLs to 7-bit ASCII and more specifically in the subset consisting of lowercase unaccented a-z, 0-9, dash, underscore and dot. It's very fun when you have Greek and can transliterate phonetically, by visual resemblance or according to the ISO standard... IMHO we should just silently let people have to use the ASCII subset as we do right now. @test Still works for me :) |
Thanks lets go for it with 3.5 as first version 👍 -> RTC Thanks @dgt41 this is awesome work This comment was created with the J!Tracker Application at issues.joomla.org/joomla-cms/7435. |
[New Feature] tinyMCE drag and drop images
@roland-d no i didn´t meant the umlauts to stay in the name like they are. It´s usual to transform ü to ue, ö to oe, ä to ae and ß to ss - currently they are completely removed with is not good :-) so should i open a new request? :-) Fun example: Übergrößenträger -> "Uebergroeßentraeger" or "bergrentrger" Edit: Oh s* sorry didn´t knew the RTC is removed by a comment - please add it again! |
@designbengel Please create an issue for it, so we don't forget about it :) The RTC has been removed because this feature has been merged. |
folder for images upload /images only ? if have many picture not good it possible upload to /images/2015/3/31/id ? |
As the title suggests: enable drag and drop
This is once again another of those @nikosdion's great ideas, as expressed in #JAB15.
The concept here is very simple: drag an image into the tinyMCE’s content area and the image should automatically be uploaded and then the correct tag should be inserted in the text area.
What’s in it?
There are some minor changes in the com_media file.json.php controller in order to incorporate the needed feedback (namely the relative url for the image) and also to make sure that the name is URL safe (no spaces allowed here).
The tinyMCE plugin introduces a new private function for building the script code required fro the functionality. That’s if the option is enabled in the back end (it is by default).
Also introduced an option for a custom solder (showable only if drag&drop is enabled) to save the images exists
The code also checks if the user is allowed to upload images.
There is a spinning joomla gif to indicate that the upload is actually happening
Also if the image gets successfully uploaded a green overlay will indicate the success
If an error happened the error will display shortly on a red background
For files dropped that are not images nothing will happen
For images that the filename already exists on the server the upload will not happen and the image that is already in the server will appear in the tinyMCE content area. (failsafe we can improve that by introducing incremental filenames as we already do for existing article aliases)
Preview
#### Testing
Apply the patch
Edit tinyMCE’s options to specify the folder for the images
Test it front end - back end