Contribute to this guide

CKFinder file manager

The CKFinder feature lets you insert images and links to files into your content. CKFinder is a powerful file manager with various image editing and image upload options.

Unlock this feature with a CKEditor Paid Plan. Sign up for a free trial, or select the Plan that provides access to all the premium features you need.

# Demos

# Image upload only

This demo shows the integration where the file manager’s server connector handles image upload only:

  • Paste an image directly into the editor. It will be automatically uploaded using the server-side connector.
  • Use the insert image button Image in the toolbar to insert an image.

CKEditor 5 offers multiple ways to include images in your rich content. You can choose whichever best suits your needs.

To upload an image, you can paste it or drag and drop it into the editor.

Alternatively, use the toolbar button to insert an image selected from your disk.

# Full integration

This demo shows the full integration with the CKFinder file uploader:

  • Paste an image directly into the editor. It will be automatically uploaded using the server-side connector.
  • Use the insert image or file button Browse files in the toolbar to open the CKFinder file manager. Then insert an image or a link to any other file.

CKEditor 5 offers multiple ways to include images in your rich content. You can choose whichever best suits your needs.

To upload an image, you can paste it or drag and drop it into the editor.

Alternatively, use the toolbar button to open the CKFinder file manager. Use the file manager's interface to insert an image or a link to a file. Thanks to CKFinder, you can also edit images, organize them into folders, or delete them from the server.

These demos present a limited set of features. Visit the feature-rich editor example to see more in action.

# Additional feature information

The CKFinder integration feature is a bridge between the CKEditor 5 WYSIWYG editor and the CKFinder file manager and uploader. CKFinder is a commercial application designed with CKEditor compatibility in mind. It is available as version 3.x for PHP, ASP.NET, and Java and version 2.x for ASP and ColdFusion.

You can use this feature in the rich-text editor in two different ways:

  • As a server-side connector only (demo). In this scenario, images dropped or pasted into the editor are uploaded to the CKFinder server-side connector running on your server.

  • As a server and client-side file manager integration (demo). Images dropped or pasted directly into the editor are uploaded to the server (just like in the first option).

    There are more cool features available, for instance:

    • Uploading using the full user interface.
    • Uploading multiple files at once.
    • Browsing previously uploaded images.
    • Editing images (cropping, resizing, etc.).
    • Organizing or deleting images.

    Check out the CKFinder file manager website to learn more about the features you can use in your project.

# Installation

⚠️ New import paths

Starting with version 42.0.0, we changed the format of import paths. This guide uses the new, shorter format. Refer to the Packages in the legacy setup guide if you use an older version of CKEditor 5.

After installing the editor, add the feature to your plugin list and toolbar configuration:

import { ClassicEditor, CKFinder, CKFinderUploadAdapter } from 'ckeditor5';

ClassicEditor
	.create( document.querySelector( '#editor' ), {
		licenseKey: '<YOUR_LICENSE_KEY>',
		plugins: [ CKFinder, CKFinderUploadAdapter, /* ... */ ],
		toolbar: [ 'ckfinder', 'uploadImage', /* ... */ ], // Depending on your preference.
		ckfinder: {
			// Configuration.
		}
	} )
	.then( /* ... */ )
	.catch( /* ... */ );

# Configuration

The feature is configurable by using the config.ckfinder object.

# Configuring the image upload only

This feature can upload images automatically to the server (for example, when the user drops an image into the content) thanks to the CKFinder upload adapter. All it requires is the correct config.ckfinder.uploadUrl path.

Assuming that you installed the CKFinder PHP server-side connector (and it is available under https://example.com/ckfinder/), use the following quick upload command URL to enable the image upload:

ClassicEditor
    .create( document.querySelector( '#editor' ), {
        // ... Other configuration options ...
        ckfinder: {
            // Upload the images to the server using the CKFinder QuickUpload command.
            uploadUrl: 'https://example.com/ckfinder/core/connector/php/connector.php?command=QuickUpload&type=Images&responseType=json'
            }
        } )
    .then( /* ... */ )
    .catch( /* ... */ );

See the demo of the image upload only.

# Configuring the full integration

To use both the image upload functionality and the file manager user interface in your application, you must first load the CKFinder JavaScript library. Then enable the CKFinder integration in your rich-text editor instance.

The easiest way to load the CKFinder library is to include the <script> tag loading the ckfinder.js file first:

<script src="https://example.com/ckfinder/ckfinder.js"></script>

Then:

  • Make sure that the CKFinder plugin for CKEditor 5 is enabled. See the Installation section.
  • To enable the automatic file upload to the server when an image is pasted or dropped into the editor content, set the correct config.ckfinder.uploadUrl path.
  • To display the toolbar button that opens the CKFinder file manager UI allowing the users to choose the files on the server, make sure that 'ckfinder' is present in your config.toolbar.
  • Additionally, you can use config.ckfinder.options to define CKFinder’s options. For example:
    • You can define options.resourceType to tell CKFinder the specified resource type can be browsed when the user clicks the button.
    • You can define options.language to set the UI language of CKFinder. By default, it will be set to the UI language of the editor.
ClassicEditor
    .create( document.querySelector( '#editor' ), {
        // ... Other configuration options ...
        ckfinder: {
            // Upload the images to the server using the CKFinder QuickUpload command.
            uploadUrl: 'https://example.com/ckfinder/core/connector/php/connector.php?command=QuickUpload&type=Images&responseType=json',

            // Define the CKFinder configuration (if necessary).
            options: {
                resourceType: 'Images'
            }
        }
    } )
    .then( /* ... */ )
    .catch( /* ... */ );

See the demo of the full integration.

# Configuring the opener

You can change the way CKFinder opens using the config.ckfinder.openerMethod option.

By default, the file manager opens as a modal. To open it in a new pop-up window, set the configuration value to popup:

ClassicEditor
    .create( document.querySelector( '#editor' ), {
        // ... Other configuration options ...
        ckfinder: {
            // Open the file manager in the pop-up window.
            openerMethod: 'popup'
        }
    } )
    .then( /* ... */ )
    .catch( /* ... */ );

# Configuring allowed file types

You should configure the allowed file types that can be uploaded in two places:

  • On the client side, in CKEditor 5, restricting image upload through the CKEditor 5 UI and commands
  • On the server side, in CKFinder, restricting the file formats accepted in CKFinder

# Client-side configuration

Use the image.upload.types configuration option to define the allowed image MIME types that the users can upload to CKEditor 5.

By default, users can upload jpeg, png, gif, bmp, webp, and tiff files, but you can customize this behavior to accept, for example, SVG files.

# Server-side configuration

Use the allowedExtensions configuration option to define the file extension allowed to be uploaded with CKFinder for a particular resource type. Refer to the relevant server-side connector documentation to learn more.

# Common API

The CKFinder plugin registers:

  • The 'ckfinder' UI button component.

  • The 'ckfinder' command implemented by the CKFinderCommand.

    You can open CKFinder by executing the following code:

    editor.execute( 'ckfinder' );
    

Additionally, in the “image upload only” integration, you can use the following button and command registered by the ImageUpload plugin:

  • The 'uploadImage' UI button component.
  • The 'uploadImage' command implemented by the UploadImageCommand.

We recommend using the official CKEditor 5 inspector for development and debugging. It will give you tons of useful information about the state of the editor such as internal data structures, selection, commands, and many more.

# What’s next

Check out the comprehensive Image upload overview to learn more about different ways of uploading images in CKEditor 5.

See the image feature guide to find out more about handling images in CKEditor 5.

# Contribute

The source code of the feature is available on GitHub at https://github.com/ckeditor/ckeditor5/tree/master/packages/ckeditor5-ckfinder.