DrupalImageStyle.php in Inline responsive images 8.2
File
src/Plugin/CKEditorPlugin/DrupalImageStyle.php
View source
<?php
namespace Drupal\inline_responsive_images\Plugin\CKEditorPlugin;
use Drupal\Component\Plugin\PluginBase;
use Drupal\editor\Entity\Editor;
use Drupal\ckeditor\CKEditorPluginInterface;
use Drupal\ckeditor\CKEditorPluginContextualInterface;
class DrupalImageStyle extends PluginBase implements CKEditorPluginInterface, CKEditorPluginContextualInterface {
public function isInternal() {
return FALSE;
}
public function getDependencies(Editor $editor) {
return [];
}
public function getLibraries(Editor $editor) {
return [];
}
public function getFile() {
return drupal_get_path('module', 'inline_responsive_images') . '/js/plugins/drupalimagestyle/plugin.js';
}
public function getConfig(Editor $editor) {
return [];
}
public function isEnabled(Editor $editor) {
if (!$editor
->hasAssociatedFilterFormat()) {
return FALSE;
}
$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;
}
}