javascriptckfinder

CKFinder: Change the default view when switching between resource types


I'm setting up CKFinder as a file browser for CKEditor and would like the defaultViewType to be different for each Resource Type. For example, when browsing the Images resource it should show thumbnails, but when browsing the Files resource it should display the "compact" view.

I have tried the following configuration, but it just shows thumbnails for both Files and Images:

defaultViewType: "thumbnails",
defaultViewType_Files: "compact"

I had considered writing a small plugin via the onInit function along the following lines:

onInit: function(finder) {
    finder.on("folder:getFiles:before", function(event) {
    var folder = finder.request("folder:getActive");
    var resource = folder.getPath({full: true}).replace(/:.*$/, "");
    switch (resource) {
        case "Files":
            finder.request("files.changeView", "compact");
            break;
        case "Images":
            finder.request("files.changeView", "thumbnails");
            break;
    });
}

But I'm not sure what request type to fire (files.changeView or similar doesn't exist).

Is it possible to achieve this either with config options or a plugin?


Solution

  • I'm not sure if you are still interested but this should help you get started: