CKEditor Image Upload

Zachary Perry asked on September 23, 2016 17:21

When using the CKEditor on the live site, if you add an image it will attach it to the current page, is it possible to override this? Maybe add some custom logic to store in a media library?

Correct Answer

Zachary Perry answered on December 2, 2016 17:17

Here is how I accomplished this.

I modified default.aspx.cs under Quickly Insert Images form control to do some logic to determine if it was the page I wanted to upload to a media library instead of attach to the current page. If it was the page I wanted, I set the sourcetype on the uploader: fileUploaderElem.SourceType = MediaSourceEnum.MediaLibraries;

Then in the DirectFileUploaderControl I modified the switch statement to check for medialibraries (which wasn't being used) and then just added the code to find the media library I wanted and add the file to it.

0 votesVote for this answer Unmark Correct answer

Recent Answers


Brenden Kehren answered on September 23, 2016 17:25

If you use a text field with a URL selector and configure the URL selector to use only the media library, you can achieve exactly what you want.

0 votesVote for this answer Mark as a Correct answer

Zachary Perry answered on September 23, 2016 17:42

Thanks Brenden, but not sure if that will accomplish what I really want.

Example: I have a form that has a field uses the Rich Text Editor control. This is basically used so a user can submit an article example, they can use the WYSIWYG to style it, and insert inline images.

I would prefer to not have to create a field for each image that they can upload, mostly because it is an unknown quantity.

I am currently using the toolbar with the "QuicklyInsertImage" button, I think I might have to use the "InsertImageOrMedia" button, and then customize what media library it has access to?

0 votesVote for this answer Mark as a Correct answer

Brenden Kehren answered on September 23, 2016 17:56

Ahh, I was thinking you had a custom page type with a long text field, my mistake.

0 votesVote for this answer Mark as a Correct answer

Laura Frese answered on September 23, 2016 18:59

If you click the film icon on the toolbar, it will provide the option to select an image from the media library.

1 votesVote for this answer Mark as a Correct answer

Zachary Perry answered on September 23, 2016 21:20

The film icon is the "InsertImageOrMedia" button, which I changed to, but I still would prefer to use the "QuicklyInsertImage" button, which just opens the upload file dialog, then on the backend control which media library it goes to. I am limiting it to one media library, but it would also be less clicks for the user to upload an image. Also they wouldn't have access to see any previous submissions files.

0 votesVote for this answer Mark as a Correct answer

   Please, sign in to be able to submit a new answer.