Skip to content

ImageSelectionModule

Auto-imported: YES (if ImageField is present in quill_options)

The ImageSelectionModule provides an interactive way to manage images within the editor. It adds a selection overlay with resize handles and a dedicated toolbar for quick actions.

This module is automatically enabled when the ImageField is used. If you don't use the ImageField but still want the module, you must add it manually to the modules option.

image selection

Features

  • Resize Handles: Drag corners to resize images proportionally.
  • Quick Alignment: Buttons for left (wrapped), left (block), center, and right alignments.
  • Preset Sizes: Quickly set width to 25%, 50%, 75%, or 100%.
  • Custom Size: Input exact width in pixels or percentage.
  • Paragraph Insertion: Buttons to quickly insert an empty paragraph before or after the image.
  • Image Transformation: Rotate (90° steps) and flip (horizontal/vertical) images.
  • Metadata Editing:
    • Captions: Add and edit image captions (requires ImageFigure blot).
    • Alt Text: Edit the alternative text for accessibility.
    • Links: Wrap images in a link.
    • Link Target: Toggle target="_blank" for image links.
  • Reset: Restore the image to its original state.
  • Delete: Quickly remove the image and its figure from the editor.

Options

OptionTypeDefaultDescription
borderColorstring'#007bff'Color of the selection border and handles.
borderWidthstring'4px'Width of the selection border.
buttonBeforeLabelstring'¶+'Label for the "insert paragraph before" button.
buttonAfterLabelstring'+¶'Label for the "insert paragraph after" button.
buttonBeforeTitlestring'Insert a paragraph before'Tooltip for the "before" button.
buttonAfterTitlestring'Insert a paragraph after'Tooltip for the "after" button.
alignLabelsarraySee belowCustom labels for alignment tooltips.
rotateLeftTitlestring'Rotate left'Tooltip for the rotate left button.
rotateRightTitlestring'Rotate right'Tooltip for the rotate right button.
flipHorizontalTitlestring'Flip horizontal'Tooltip for the flip horizontal button.
flipVerticalTitlestring'Flip vertical'Tooltip for the flip vertical button.
resetTitlestring'Reset image'Tooltip for the reset button.
deleteTitlestring'Delete image'Tooltip for the delete button.
linkTitlestring'Edit link'Tooltip for the link button.
linkTargetTitlestring'Open in new tab'Tooltip for the link target toggle.
captionBackgroundColorstring'rgba(51, 51, 51, 0.6)'Background color of the caption overlay.
sectionLabelsarraySee belowSmall labels displayed above toolbar sections. To disable, pass an empty array [].

alignLabels default values

php
'alignLabels' => [
    'left' => 'Left (wrapped)',
    'leftBlock' => 'Left (no wrap)',
    'center' => 'Align center',
    'right' => 'Right (wrapped)',
]

sectionLabels default values

php
'sectionLabels' => [
    'size' => 'Size',
    'align' => 'Align',
    'image' => 'Image',
    'meta' => 'Content',
    'insert' => 'Insert',
]

Usage example

Although it's usually auto-imported, you can manually configure it with custom options:

php
use Ehyiah\QuillJsBundle\DTO\Modules\ImageSelectionModule;

// ...

'modules' => [
    new ImageSelectionModule([
        'borderColor' => '#ff0000',
        'buttonBeforeLabel' => 'Insert Before',
        'alignLabels' => [
            'center' => 'Centrer l'image',
        ],
    ]),
],

Using Legacy ResizeModule

If you prefer the old image resizing behavior, you can disable ImageSelectionModule and enable ResizeModule instead:

image selection legacy
php
use Ehyiah\QuillJsBundle\DTO\Modules\ImageSelectionModule;
use Ehyiah\QuillJsBundle\DTO\Modules\ResizeModule;

// ...

'modules' => [
    new ImageSelectionModule(['options' => false]), // Disable the new module
    new ResizeModule(), // Enable the old one
],