Image styles 

This extension provides two ways to apply styles to images in the editor. Understanding the difference is important for choosing the right approach.

Overview: Two styling approaches 

Native CKEditor style dropdown (advanced) 

For custom styles beyond basic alignment, you can use the native CKEditor style dropdown. This requires additional configuration.

Requirements 

  1. Add style to your toolbar configuration.
  2. Define style definitions for img elements.
  3. Ensure StyleUtils and GeneralHtmlSupport plugins are loaded (automatic).

Configuration example 

EXT:my_site/Configuration/RTE/MyPreset.yaml
imports:
  - { resource: "EXT:rte_ckeditor_image/Configuration/RTE/Default.yaml" }

editor:
  config:
    # Add 'style' to the toolbar
    toolbar:
      items:
        - style           # <-- Required for style dropdown
        - heading
        - '|'
        - insertimage
        - link
        - '|'
        - bold
        - italic

    # Define styles for images
    style:
      definitions:
        - name: 'Float Left (Bootstrap)'
          element: 'img'
          classes: ['float-start', 'me-3', 'mb-3']
        - name: 'Float Right (Bootstrap)'
          element: 'img'
          classes: ['float-end', 'ms-3', 'mb-3']
        - name: 'Centered'
          element: 'img'
          classes: ['d-block', 'mx-auto']
        - name: 'Rounded'
          element: 'img'
          classes: ['rounded']
        - name: 'Thumbnail'
          element: 'img'
          classes: ['img-thumbnail']
Copied!

How to use 

  1. Insert an image.
  2. Select the image (click on it).
  3. Open the Style dropdown in the main toolbar.
  4. Select a style from the dropdown.

The style dropdown groups the definitions automatically into block styles and text styles. CKEditor 5 has no option for custom style groups.

Troubleshooting 

Style dropdown not appearing 

Symptoms: No "Styles" dropdown visible in the toolbar.

Solution: Add style to your toolbar configuration:

editor:
  config:
    toolbar:
      items:
        - style    # <-- Add this
        - heading
        - insertimage
        # ...
Copied!

Styles disabled when image selected 

Symptoms: Style dropdown shows options but they're grayed out for images.

Cause: Missing dependencies or incorrect style definitions.

Solution: Verify your style definitions target img elements:

style:
  definitions:
    - name: 'My Image Style'
      element: 'img'      # <-- Must be 'img'
      classes: ['my-class']
Copied!

Balloon toolbar not showing 

Symptoms: No toolbar appears when clicking an image.

Solution: Ensure you're using the rteWithImages preset or a preset that imports the image plugin.

Check your preset includes the image plugin
imports:
  - { resource: "EXT:rte_ckeditor_image/Configuration/RTE/Default.yaml" }
Copied!

Choosing the right approach 

Feature Balloon Toolbar (Built-in) Style Dropdown (Native)
Configuration None required YAML configuration needed
Styles available 4 alignment options (left, center, right, block) plus inline/block toggle Custom (you define them)
Location Balloon above image Main toolbar dropdown
Best for Basic alignment Custom Bootstrap/CSS classes
CSS included Yes (image-alignment.css) No (provide your own)

Recommendation: Start with the built-in balloon toolbar. Only configure the native style dropdown if you need custom CSS classes beyond the basic alignments.