Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. Image.php

class Image

Same name in this branch
  1. 11.1.x vendor/symfony/validator/Constraints/Image.php \Symfony\Component\Validator\Constraints\Image
  2. 11.1.x vendor/symfony/dom-crawler/Image.php \Symfony\Component\DomCrawler\Image
  3. 11.1.x core/lib/Drupal/Core/Image/Image.php \Drupal\Core\Image\Image
  4. 11.1.x core/lib/Drupal/Component/Utility/Image.php \Drupal\Component\Utility\Image
  5. 11.1.x core/modules/media/src/Plugin/media/Source/Image.php \Drupal\media\Plugin\media\Source\Image

CKEditor 5 Image plugin.

@internal Plugin classes are internal.

Hierarchy

  • class \Drupal\Component\Plugin\PluginBase implements \Drupal\Component\Plugin\PluginInspectionInterface, \Drupal\Component\Plugin\DerivativeInspectionInterface
    • class \Drupal\Core\Plugin\PluginBase extends \Drupal\Component\Plugin\PluginBase uses \Drupal\Core\StringTranslation\StringTranslationTrait, \Drupal\Core\DependencyInjection\DependencySerializationTrait, \Drupal\Core\Messenger\MessengerTrait
      • class \Drupal\ckeditor5\Plugin\CKEditor5PluginDefault extends \Drupal\Core\Plugin\PluginBase implements \Drupal\ckeditor5\Plugin\CKEditor5PluginInterface
        • class \Drupal\ckeditor5\Plugin\CKEditor5Plugin\Image extends \Drupal\ckeditor5\Plugin\CKEditor5PluginDefault implements \Drupal\ckeditor5\Plugin\CKEditor5PluginConfigurableInterface uses \Drupal\ckeditor5\Plugin\CKEditor5PluginConfigurableTrait, \Drupal\ckeditor5\Plugin\CKEditor5Plugin\DynamicPluginConfigWithCsrfTokenUrlTrait

Expanded class hierarchy of Image

130 string references to 'Image'
banner.component.yml in core/profiles/demo_umami/themes/umami/components/banner/banner.component.yml
core/profiles/demo_umami/themes/umami/components/banner/banner.component.yml
BrowserKitDriver::canSubmitForm in vendor/behat/mink-browserkit-driver/src/BrowserKitDriver.php
BrowserKitDriver::getFormField in vendor/behat/mink-browserkit-driver/src/BrowserKitDriver.php
Returns form field from XPath query.
BrowserKitDriver::getValue in vendor/behat/mink-browserkit-driver/src/BrowserKitDriver.php
Returns element's value by its XPath query.
BrowserKitDriver::mergeForms in vendor/behat/mink-browserkit-driver/src/BrowserKitDriver.php
Merges second form values into first one.

... See full list

File

core/modules/ckeditor5/src/Plugin/CKEditor5Plugin/Image.php, line 20

Namespace

Drupal\ckeditor5\Plugin\CKEditor5Plugin
View source
class Image extends CKEditor5PluginDefault implements CKEditor5PluginConfigurableInterface {
    use CKEditor5PluginConfigurableTrait;
    use DynamicPluginConfigWithCsrfTokenUrlTrait;
    
    /**
     * {@inheritdoc}
     */
    public function getDynamicPluginConfig(array $static_plugin_config, EditorInterface $editor) : array {
        $config = $static_plugin_config;
        if ($editor->getImageUploadSettings()['status'] === TRUE) {
            $config += [
                'drupalImageUpload' => [
                    'uploadUrl' => self::getUrlWithReplacedCsrfTokenPlaceholder(Url::fromRoute('ckeditor5.upload_image')->setRouteParameter('editor', $editor->getFilterFormat()
                        ->id())),
                    'withCredentials' => TRUE,
                    'headers' => [
                        'Accept' => 'application/json',
                        'text/javascript',
                    ],
                ],
            ];
            $config['image']['insert']['integrations'][] = 'upload';
        }
        else {
            $config['image']['insert']['integrations'][] = 'url';
        }
        return $config;
    }
    
    /**
     * {@inheritdoc}
     *
     * @see editor_image_upload_settings_form()
     */
    public function buildConfigurationForm(array $form, FormStateInterface $form_state) {
        $form_state->loadInclude('editor', 'admin.inc');
        return editor_image_upload_settings_form($form_state->get('editor'));
    }
    
    /**
     * {@inheritdoc}
     */
    public function validateConfigurationForm(array &$form, FormStateInterface $form_state) {
        $form_state->setValue('status', (bool) $form_state->getValue('status'));
        $directory = $form_state->getValue([
            'directory',
        ]);
        $form_state->setValue([
            'directory',
        ], trim($directory) === '' ? NULL : $directory);
        $max_size = $form_state->getValue([
            'max_size',
        ]);
        $form_state->setValue([
            'max_size',
        ], trim($max_size) === '' ? NULL : $max_size);
        $max_width = $form_state->getValue([
            'max_dimensions',
            'width',
        ]);
        $form_state->setValue([
            'max_dimensions',
            'width',
        ], trim($max_width) === '' ? NULL : (int) $max_width);
        $max_height = $form_state->getValue([
            'max_dimensions',
            'height',
        ]);
        $form_state->setValue([
            'max_dimensions',
            'height',
        ], trim($max_height) === '' ? NULL : (int) $max_height);
    }
    
    /**
     * {@inheritdoc}
     */
    public function submitConfigurationForm(array &$form, FormStateInterface $form_state) {
        $settings = $form_state->getValues();
        if (!$settings['status']) {
            // Remove all other settings to comply with config schema.
            $settings = [
                'status' => FALSE,
            ];
        }
        // Store this configuration in its out-of-band location.
        $form_state->get('editor')
            ->setImageUploadSettings($settings);
    }
    
    /**
     * {@inheritdoc}
     *
     * This returns an empty array as image upload config is stored out of band.
     */
    public function defaultConfiguration() {
        return [];
    }

}

Members

Title Sort descending Modifiers Object type Summary Overriden Title Overrides
CKEditor5PluginConfigurableTrait::getConfiguration public function
CKEditor5PluginConfigurableTrait::setConfiguration public function
CKEditor5PluginDefault::__construct public function 3
DynamicPluginConfigWithCsrfTokenUrlTrait::getUrlWithReplacedCsrfTokenPlaceholder private static function Gets the given URL with all placeholders replaced.
Image::buildConfigurationForm public function
Image::defaultConfiguration public function This returns an empty array as image upload config is stored out of band.
Image::getDynamicPluginConfig public function Allows a plugin to modify its static configuration. Overrides CKEditor5PluginDefault::getDynamicPluginConfig
Image::submitConfigurationForm public function
Image::validateConfigurationForm public function
PluginInspectionInterface::getPluginDefinition public function Gets the definition of the plugin implementation. 5
PluginInspectionInterface::getPluginId public function Gets the plugin ID of the plugin instance. 2

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal