public function DrupalImageStyle::isEnabled in Inline responsive images 8.2
Checks if this plugin should be enabled based on the editor configuration.
The editor's settings can be retrieved via $editor->getSettings().
Parameters
\Drupal\editor\Entity\Editor $editor: A configured text editor object.
Return value
bool
Overrides CKEditorPluginContextualInterface::isEnabled
File
- src/
Plugin/ CKEditorPlugin/ DrupalImageStyle.php, line 64 - Contains \Drupal\inline_responsive_images\Plugin\CKEditorPlugin\DrupalImageStyle.
Class
- DrupalImageStyle
- Defines the "drupalimagestyle" plugin.
Namespace
Drupal\inline_responsive_images\Plugin\CKEditorPluginCode
public function isEnabled(Editor $editor) {
if (!$editor
->hasAssociatedFilterFormat()) {
return FALSE;
}
// Automatically enable this plugin if the text format associated with this
// text editor uses the filter_imagestyle filter and the DrupalImage button
// is enabled.
$format = $editor
->getFilterFormat();
if ($format
->filters('filter_imagestyle')->status) {
$enabled = FALSE;
$settings = $editor
->getSettings();
foreach ($settings['toolbar']['rows'] as $row) {
foreach ($row as $group) {
foreach ($group['items'] as $button) {
if ($button === 'DrupalImage') {
$enabled = TRUE;
}
}
}
}
return $enabled;
}
return FALSE;
}