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.
Table of Contents
Overview: Two styling approaches
Important
There are two separate styling systems:
- Built-in balloon toolbar (works out of the box)
- Native CKEditor style dropdown (requires configuration)
Most users should use the built-in balloon toolbar which works
automatically with the rte preset.
Built-in balloon toolbar (recommended)
The extension provides built-in image alignment buttons that appear in a balloon toolbar when you click on an image.
No configuration required - works out of the box with the
rte preset.
Available styles
| Button | CSS Class | Effect |
|---|---|---|
| Align Left | image- | Float left with text wrap |
| Align Center | image- | Centered block element |
| Align Right | image- | Float right with text wrap |
| Block | image- | Full-width block element |
The toolbar also has an edit button, a caption toggle and a button that
switches the image between block and inline type. An inline image gets the
image- class.
How to use
- Insert an image using the Insert Image button in the toolbar.
- Click on the image in the editor.
- A balloon toolbar appears above the image with alignment buttons.
- Click an alignment button to apply the style.
Note
The balloon toolbar appears directly above the selected image with icons for editing, caption, image type (block or inline) and alignment (left, center, right, block).
Toolbar items
The balloon toolbar is defined in the plugin (typo3image.) and is not
configurable. It contains these items:
editTypo3Image | toggleImageCaption | toggleImageType |
imageStyle:image-left, imageStyle:image-center,
imageStyle:image-right, imageStyle:image-block
Note
rte contains a typo3image. list, but the
plugin does not read it. Changing it has no effect.
CSS styles
The extension provides CSS styles in image-:
.image-left { float: left; margin: 0 1rem 1rem 0; clear: left; }
.image-right { float: right; margin: 0 0 1rem 1rem; clear: right; }
.image-center { display: block; margin-left: auto; margin-right: auto; margin-bottom: 1rem; }
.image-inline { display: inline-block; vertical-align: middle; margin: 0 0.25rem; }
.image-block { display: block; width: 100%; margin: 1rem 0; }
Tip
The Site Set includes this CSS in the frontend. Without the Site Set, include it yourself:
page {
includeCSS {
imageAlignment = EXT:rte_ckeditor_image/Resources/Public/Css/image-alignment.css
}
}
Caption width constraint
New in version 13.6.0
Figures with captions are automatically constrained to the image width
via an inline max- style on the <figure> element. This
prevents long caption text from expanding the figure beyond the image
boundary.
Left: caption overflows image. Right: caption wraps within image width.
The constraint is applied by the Fluid partial
Partials/:
<figure class="{figureClasses}{additionalClass}"
{f:if(condition: image.width,
then: ' style="max-width: {image.width}px"')}>
Long unbreakable words or URLs in captions break via
overflow- in image-.
Native CKEditor style dropdown (advanced)
For custom styles beyond basic alignment, you can use the native CKEditor style dropdown. This requires additional configuration.
Important
The native style dropdown is separate from the built-in balloon toolbar buttons. Use this approach when you need custom CSS classes (e.g., Bootstrap utilities).
Requirements
- Add
styleto your toolbar configuration. - Define style definitions for
imgelements. - Ensure
StyleandUtils Generalplugins are loaded (automatic).Html Support
Configuration example
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']
How to use
- Insert an image.
- Select the image (click on it).
- Open the Style dropdown in the main toolbar.
- Select a style from the dropdown.
Note
The style dropdown only shows styles applicable to the selected element. Make sure you have the image selected when looking for image styles.
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
# ...
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']
Balloon toolbar not showing
Symptoms: No toolbar appears when clicking an image.
Solution: Ensure you're using the rte preset or a preset
that imports the image plugin.
imports:
- { resource: "EXT:rte_ckeditor_image/Configuration/RTE/Default.yaml" }
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.