Image block tool for Editor.js
npm install @coolbytes/editorjs-imageThis Editor.js block tool allows you to add images. This implementation is directly taken from the Editor.js Docs.
#### Block Tool
!image
#### Block Settings
!settings
Using npm
``sh`
npm install @coolbytes/editorjs-image
Using yarn
`sh`
yarn add @coolbytes/editorjs-image
Include it in the tools property of Editor.js config:
`js`
const editor = new EditorJS({
tools: {
image: Image
}
});
|Field|Type|Optional|Default|Description|
|---|---|---|---|---|
|imageAlt|string|Yes|_picture_|Alternate text for images|boolean
|enableCaption||Yes|false|Flag to enable image caption|string
|captionPlaceholder||Yes|_Enter a caption_|Placeholder text for image caption|
`js`
const editor = EditorJS({
tools: {
image: {
class: Image,
inlineToolbar: true,
config: {
enableCaption: true,
captionPlaceholder: 'Enter a caption'
}
}
}
});
|Field|Type|Description|
|---|---|---|
|url|string|Image src URL|string
|caption||Image caption|boolean
|withBorder||Indicates if image border is added|boolean
|withBackground||Indicates if image background is added|boolean
|stretched||Indicates if image is stretched|
Example:
`json``
{
"time": 1715969561758,
"blocks": [
{
"id": "_K5QcJHHuK",
"type": "image",
"data": {
"url": "https://cdn.pixabay.com/photo/2017/09/01/21/53/blue-2705642_1280.jpg",
"caption": "Source: Editor.js",
"withBorder": true,
"stretched": true,
"withBackground": false
}
}
],
"version": "2.29.1"
}