0

I need to change the settings for the image upload dialog in TinyMCE to remove the Advanced Tab.

Advanced tab in Upload image dialog of TingMCE

I've already changed settings of the tool bar icons successfully by creating:

<type name="\Magento\Cms\Model\Wysiwyg\Config">
    <plugin name="add_wysiwyg_data" type="\Hidden\System\Plugin\WysiwygConfig" sortOrder="10" />
</type>

and

namespace Hidden\System\Plugin;

class WysiwygConfig
{
    public function afterGetConfig($subject, \Magento\Framework\DataObject $config)
    {
        $styleArray = [
            'Hero - Image' => 'hero__image',
            'Hero - Heading' => 'hero__heading',
            'Hero - Action Button' => 'hero__primary-action'
        ];

        $styles = array_map(function ($title, $class) {
            return "{$title}={$class}; ";
        }, array_keys($styleArray), array_values($styleArray));

        $config->addData(
            ["settings" =>
                ["theme_advanced_styles" => implode("; ", $styles),
                    "theme_advanced_buttons1" => "magentovairable,magentowidget,styleselect,formatselect,bold,italic,underline,|,bullist,numlist,link,unlink,anchor,image",
                    "theme_advanced_buttons2" => "undo,redo,cut,copy,paste,pastetext,|,search,replace,|,outdent,indent,blockquote,|,removeformat,sub,sup,|,charmap,iespell,|,fullscreen",
                    "theme_advanced_buttons3" => "",
                    "theme_advanced_buttons4" => ""]]);

        $config->addData(["image_dimensions" => false]);
        $config->addData(["image_advtab" => false]);

        return $config;
    }

As you can see I have tried to add the config data to disable image_dimensions and image_advtab but to no effect, I have also tried having this as elements of the previous $config->addData (under settings).

I got these settings from this documentation, but the docs for the version of TinyMCE in Magento 2 aren't that great.

I think I must be barking completely up the wrong tree, how can I disable this tab?

2

There is no such way to disable tab:

You can find config values here:

/vendor/magento/module-cms/Model/Wysiwyg/Config.php

If you want to disable it you can modify HTML file.

Path: /lib/web/tiny_mce/plugins/advimage/image.htm

Line 20:

<li id="advanced_tab" aria-controls="advanced_panel"><span><a href="javascript:mcTabs.displayTab('advanced_tab','advanced_panel');" onmousedown="return false;">{#advimage_dlg.tab_advanced}</a></span></li>

Comment this code.

  • Thanks, I am glad I can stop chasing something! Hacking it in the core is not ideal, but necessary in this case. – tim.baker May 1 '17 at 20:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.