You are here

class DrupalImageStyle in Inline responsive images 7

Same name and namespace in other branches
  1. 8 src/Plugin/CKEditorPlugin/DrupalImageStyle.php \Drupal\inline_responsive_image\Plugin\CKEditorPlugin\DrupalImageStyle

Defines the "drupalimagestyle" plugin.

Plugin annotation


@CKEditorPlugin(
  id = "drupalimagestyle",
  label = @Translation("Drupal image style widget"),
  module = "ckeditor"
)

Hierarchy

  • class \Drupal\inline_responsive_image\Plugin\CKEditorPlugin\DrupalImageStyle extends \Drupal\Component\Plugin\PluginBase implements \Drupal\ckeditor\CKEditorPluginInterface, \Drupal\ckeditor\CKEditorPluginContextualInterface

Expanded class hierarchy of DrupalImageStyle

File

src/Plugin/CKEditorPlugin/DrupalImageStyle.php, line 19

Namespace

Drupal\inline_responsive_image\Plugin\CKEditorPlugin
View source
class DrupalImageStyle extends PluginBase implements CKEditorPluginInterface, CKEditorPluginContextualInterface {

  /**
   * {@inheritdoc}
   */
  public function isInternal() {
    return FALSE;
  }

  /**
   * {@inheritdoc}
   */
  public function getDependencies(Editor $editor) {
    return array();
  }

  /**
   * {@inheritdoc}
   */
  public function getLibraries(Editor $editor) {
    return array(
      'inline_responsive_image/drupal.ckeditor.plugins.drupalimagestyle',
    );
  }

  /**
   * {@inheritdoc}
   */
  public function getFile() {
    return drupal_get_path('module', 'inline_responsive_image') . '/js/plugins/drupalimagestyle/plugin.js';
  }

  /**
   * {@inheritdoc}
   */
  public function getConfig(Editor $editor) {
    $format = $editor
      ->getFilterFormat();
    return array();
  }

  /**
   * {@inheritdoc}
   */
  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_align or filter_caption filter and the
    // DrupalImage button is enabled.
    $format = $editor
      ->getFilterFormat();
    if ($format
      ->filters('filter_align')->status || $format
      ->filters('filter_caption')->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;
  }

}

Members