November Happy Hour will be moved to Thursday December 5th.

Disable "open in image editor" when inheriting from ImageData

Vote:
 

I've created a content type that inherits from ImageData but I don't want the editors to be able to modify the image through the editor. Removing the edit permissions to the image doesn't seem to remove the menu option to open the image editor and only shows an "insufficient permissions" dialog when an editor tries to save the image in the editor.

Is it possible to disable/remove the option "open in image editor" from the UI for a specific content type?

#198828
Nov 07, 2018 10:39
Vote:
 

You can turn off image editor for all type of images using web.config.

https://world.episerver.com/documentation/Items/Developers-Guide/Episerver-CMS/7/Configuration/Configuring-episerver-Section/#imageEditor

There is no supported way to turn off images only for one specific type. But I prepared a hack that you could use:

Here is the initializer (that should be registered in module.config):

define([
    "dojo/_base/declare",
    "epi/_Module",
    "epi-cms/command/EditImage"
], function (
    declare,
    module,
    EditImage
) {
    return declare([module], {

        initialize: function () {
            this.inherited(arguments);

            var original = EditImage.prototype._onModelChange;
            EditImage.prototype._onModelChange = function () {
                var result = original.apply(this, arguments);

                if (!this.get("isAvailable")) {
                    return result;
                }

                var target = this._getSingleSelectionData(),
                    canExecute = target && target.typeIdentifier !== "alloytemplates.models.media.tiffimagefile";

                if (!canExecute) {
                    this.set("isAvailable", false);
                    this.set("canExecute", false);
                }
                return result;
            }
        }
    });
});

My Tiff model looks like this:

[ContentType(GUID = "4D3B327B-4A1C-42ED-9A62-E8D4F925B8F7")]
[MediaDescriptor(ExtensionString = "tif,tiff")]
public class TiffImageFile : ImageData 
{
    public virtual string Copyright { get; set; }
}

#198924
Nov 08, 2018 22:07
Vote:
 

That's great! Thanks for the help!

#199180
Nov 19, 2018 14:58
This topic was created over six months ago and has been resolved. If you have a similar question, please create a new topic and refer to this one.
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.