Image position
Makes the image on the right, left or center of the text.
Click on the image to see the Image Position icon on the toolbar.
Code
<!DOCTYPE html>
<html>
<head>
<title>Redactor</title>
<meta charset="utf-8">
<!-- css -->
<link rel="stylesheet" href="/your-folder/redactorx.css" />
</head>
<body>
<!-- element -->
<textarea id="entry">...</textarea>
<!-- js -->
<script src="/your-folder/redactorx.js"></script>
<script src="/your-folder/plugins/imageposition.js"></script>
<!-- call -->
<script>
RedactorX('#entry', {
plugins: ['imageposition']
});
</script>
</body>
</html>
Usage
By default, the editor sets these CSS classes for image position:
left: 'float-left',
center: 'align-center',
right: 'float-right'
This means that in the output code the image will have a class and will look like this:
<figure class="float-left">
<img src="...">
</figure>
You can change to your classes by specifying them in the settings when you start the editor.
RedactorX('#entry', {
plugins: ['imageposition'],
imageposition: {
items: {
left: 'my-float-left',
center: 'my-align-center',
right: 'my-float-right'
}
}
});
Now a class will be set into a block tag as specified in the settings.
<figure class="my-float-left">
<img src="...">
</figure>
You also need to add styles for the editable layer, so that the styles of these classes are applied in the editor view. For example:
.rx-content .my-float-left {
float: left;
max-width: 500px;
}
.rx-content .my-float-right {
float: right;
max-width: 500px;
}
.rx-content figure.my-align-center,
.rx-content figure figcaption {
text-align: center;
}
.rx-content figure.my-align-center img {
max-width: 500px;
}
Using the settings, you can disable unnecessary image position items.
RedactorX('#entry', {
plugins: ['imageposition'],
imageposition: {
items: {
center: false
}
}
});