Adds a drag handle on focused image blocks for resizing by width (height follows aspect ratio). No toolbar button — select an image block and drag the blue handle on the right edge.
Works automatically when an image block is focused. Minimum dimensions are controlled by plugin options.
<script src="/assets/redactor/redactor.js"></script>
<script src="/assets/redactor/plugins/image-resize/image-resize.js"></script>
const app = Redactor('#entry', {
plugins: ['imageResize']
});
number)
80number)
10Redactor('#entry', {
plugins: ['imageResize'],
imageResize: {
minWidth: 120,
minHeight: 20
}
});
en: {
imageResize: {
'image-resize': 'Image resize'
}
}
This plugin emits editor-level image resize events (not namespaced to the plugin instance):
Resizing begins.
Payload: { event, block, blockEl, imageEl }
Resizing ends and dimensions are saved.
Payload: { event, block, blockEl, imageEl }
app.on('image:resize:stop', ({ block }) => {
console.log('Resized', block.getImageEl()?.getAttribute('width'));
});
Removes the resize handle and unbinds resize listeners.
app.imageResize.stop();
Repositions the resize handle after layout changes (for example image wrap or alignment).
app.imageResize.updatePosition();