Git Product home page Git Product logo

image's Introduction

Image Tool

Image Block for the Editor.js.

Features

  • Uploading file from the device
  • Pasting copied content from the web
  • Pasting images by drag-n-drop
  • Pasting files and screenshots from Clipboard
  • Allows adding a border, and a background
  • Allows stretching an image to the container's full-width

Notes

This Tool requires server-side implementation for the file uploading. See backend response format for more details.

This Tool is also capable of uploading & displaying video files using the <video> element. To enable this, specify video mime-types via the 'types' config param.

Installation

Get the package

yarn add @editorjs/image

Include module at your application

import ImageTool from '@editorjs/image';

Optionally, you can load this tool from JsDelivr CDN

Usage

Add a new Tool to the tools property of the Editor.js initial config.

import ImageTool from '@editorjs/image';

// or if you inject ImageTool via standalone script
const ImageTool = window.ImageTool;

var editor = EditorJS({
  ...

  tools: {
    ...
    image: {
      class: ImageTool,
      config: {
        endpoints: {
          byFile: 'http://localhost:8008/uploadFile', // Your backend file uploader endpoint
          byUrl: 'http://localhost:8008/fetchUrl', // Your endpoint that provides uploading by Url
        }
      }
    }
  }

  ...
});

Config Params

Image Tool supports these configuration parameters:

Field Type Description
endpoints {byFile: string, byUrl: string} Endpoints for file uploading.
Contains 2 fields:
byFile - for file uploading
byUrl - for uploading by URL
field string (default: image) Name of uploaded image field in POST request
types string (default: image/*) Mime-types of files that can be accepted with file selection.
additionalRequestData object Object with any data you want to send with uploading requests
additionalRequestHeaders object Object with any custom headers which will be added to request. See example
captionPlaceholder string (default: Caption) Placeholder for Caption input
buttonContent string Allows to override HTML content of «Select file» button
uploader {{uploadByFile: function, uploadByUrl: function}} Optional custom uploading methods. See details below.
actions array Array with custom actions to show in the tool's settings menu. See details below.

Note that if you don't implement your custom uploader methods, the endpoints param is required.

Tool's settings

  1. Add border

  2. Stretch to full-width

  3. Add background

Add extra setting-buttons by adding them to the actions-array in the configuration:

actions: [
    {
        name: 'new_button',
        icon: '<svg>...</svg>',
        title: 'New Button',
        toggle: true,
        action: (name) => {
            alert(`${name} button clicked`);
        }
    }
]

NOTE: return value of action callback for settings whether action button should be toggled or not is deprecated. Consider using toggle option instead.

Output data

This Tool returns data with following format

Field Type Description
file object Uploaded file data. Any data got from backend uploader. Always contain the url property
caption string image's caption
withBorder boolean add border to image
withBackground boolean need to add background
stretched boolean stretch image to screen's width
{
    "type" : "image",
    "data" : {
        "file": {
            "url" : "https://www.tesla.com/tesla_theme/assets/img/_vehicle_redesign/roadster_and_semi/roadster/hero.jpg"
        },
        "caption" : "Roadster // tesla.com",
        "withBorder" : false,
        "withBackground" : false,
        "stretched" : true
    }
}

Backend response format

This Tool works by one of the following schemes:

  1. Uploading files from the device
  2. Uploading by URL (handle image-like URL's pasting)
  3. Uploading by drag-n-drop file
  4. Uploading by pasting from Clipboard

Uploading files from device

Scenario:

  1. User select file from the device
  2. Tool sends it to your backend (on config.endpoints.byFile route)
  3. Your backend should save file and return file data with JSON at specified format.
  4. Image tool shows saved image and stores server answer

So, you can implement backend for file saving by your own way. It is a specific and trivial task depending on your environment and stack.

The tool executes the request as multipart/form-data, with the key as the value of field in configuration.

The response of your uploader should cover the following format:

{
    "success" : 1,
    "file": {
        "url" : "https://www.tesla.com/tesla_theme/assets/img/_vehicle_redesign/roadster_and_semi/roadster/hero.jpg",
        // ... and any additional fields you want to store, such as width, height, color, extension, etc
    }
}

success - uploading status. 1 for successful, 0 for failed

file - uploaded file data. Must contain an url field with full public path to the uploaded image. Also, can contain any additional fields you want to store. For example, width, height, id etc. All additional fields will be saved at the file object of output data.

Uploading by pasted URL

Scenario:

  1. User pastes an URL of the image file to the Editor
  2. Editor pass pasted string to the Image Tool
  3. Tool sends it to your backend (on config.endpoints.byUrl route) via 'url' in request body
  4. Your backend should accept URL, download and save the original file by passed URL and return file data with JSON at specified format.
  5. Image tool shows saved image and stores server answer

The tool executes the request as application/json with the following request body:

{
  "url": "<pasted URL from the user>"
  "additionalRequestData": "<additional request data from configuration>"
}

Response of your uploader should be at the same format as described at «Uploading files from device» section

Uploading by drag-n-drop or from Clipboard

Your backend will accept file as FormData object in field name, specified by config.field (by default, «image»). You should save it and return the same response format as described above.

Providing custom uploading methods

As mentioned at the Config Params section, you have an ability to provide own custom uploading methods. It is a quite simple: implement uploadByFile and uploadByUrl methods and pass them via uploader config param. Both methods must return a Promise that resolves with response in a format that described at the backend response format section.

Method Arguments Return value Description
uploadByFile File {Promise.<{success, file: {url}}>} Upload file to the server and return an uploaded image data
uploadByUrl string {Promise.<{success, file: {url}}>} Send URL-string to the server, that should load image by this URL and return an uploaded image data

Example:

import ImageTool from '@editorjs/image';

var editor = EditorJS({
  ...

  tools: {
    ...
    image: {
      class: ImageTool,
      config: {
        /**
         * Custom uploader
         */
        uploader: {
          /**
           * Upload file to the server and return an uploaded image data
           * @param {File} file - file selected from the device or pasted by drag-n-drop
           * @return {Promise.<{success, file: {url}}>}
           */
          uploadByFile(file){
            // your own uploading logic here
            return MyAjax.upload(file).then(() => {
              return {
                success: 1,
                file: {
                  url: 'https://codex.so/upload/redactor_images/o_80beea670e49f04931ce9e3b2122ac70.jpg',
                  // any other image data you want to store, such as width, height, color, extension, etc
                }
              };
            });
          },

          /**
           * Send URL-string to the server. Backend should load image by this URL and return an uploaded image data
           * @param {string} url - pasted image URL
           * @return {Promise.<{success, file: {url}}>}
           */
          uploadByUrl(url){
            // your ajax request for uploading
            return MyAjax.upload(file).then(() => {
              return {
                success: 1,
                file: {
                  url: 'https://codex.so/upload/redactor_images/o_e48549d1855c7fc1807308dd14990126.jpg',,
                  // any other image data you want to store, such as width, height, color, extension, etc
                }
              }
            })
          }
        }
      }
    }
  }

  ...
});

image's People

Contributors

anderstornkvist avatar calumk avatar dependabot[bot] avatar dependentmadani avatar duncank avatar gincher avatar gohabereg avatar goldenjaden avatar jschanker avatar nespecc avatar rmlamarche avatar robonetphy avatar smallhillcz avatar sosie-js avatar talyguryn avatar tatianafomina avatar tetreum avatar zdebra avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

image's Issues

How to use with existing file manager

Sorry is this is obvious, but I cannot wrap my head around making custom blocks. I have an existing file manager in a CMS I'm working on. Is there a callback I can use to insert a block with the image I pick from my file manager?

Allow changing the image after insertion

It would be nice if we have a way to change the image after insertion. A typical use-case is that the application presents a template, with a placeholder image, which the user can change by uploading their own image. Currently, it's not easy to discover how to insert an image block; by having the placeholder (and allowing the user to change it), it will make the block much easier to use.

Store image as Buffer

what if i want to store the image in database buffer instead of having the image in a separate folder.

MIME type not passed to ajax when using custom uploader

If a custom uploader with uploadByFile is used, the mime type specified with types is not used, neither is image/*. Instead, the default of the ajax libary */* is used. Especially on mobile devices this is annoying since the general file picker instead of the image file picker is opened.

Cannot read property

Cannot read property 'config' of undefined
Uncaught TypeError: Cannot read property 'holder' of undefined
Uncaught TypeError: Cannot read property 'holder' of undefined
editor.js:22 Uncaught TypeError: Cannot read property 'config' of undefined
editor.js:12 Uncaught TypeError: Cannot read property 'holder' of undefined

this is my code
`<script>
$(document).ready(function () {
const ImageTool = window.ImageTool;
var editor = new EditorJS({
tools: {
header: {
class: Header,
inlineToolbar: true,
config: {
placeholder: 'Header'
},

                },
                list: {
                    class: List,
                    inlineToolbar: true,
                },
                image: {
                    class: ImageTool,
                    config: {
                        endpoints: {
                            byFile: 'http://localhost:8008/uploadFile', // Your backend file uploader endpoint
                            byUrl: 'http://localhost:8008/fetchUrl', // Your endpoint that provides uploading by Url
                        }

                    }
                }


            },

            holderId: 'edjs'

        });

    });
</script>`

this is my first time i use Editor Js it is perfect editor i always use TinyMCE but I love This Editor
by the way i downloaded
header and List
header and List Work but Image didn't work

Show Image Without Uploading to Server

Hi , how to show the image in dom without uploading to server like in tinymce , I want to upload the content and image at last so please let me know how to do that

Upload by URL is not appearing in the editor

I've configured my app with the code from your README but when I try to add a new image block it simply brings me to the file explorer. Is this expected behavior and I'm getting something wrong, or is this a bug I should report in more detail?

Add request handlers

Can you add handlers to endpoints.
If you look at the backend side, yes, it's easier to just specify the url and line up the backend with the format you want. But if you look at it from the frontend side, it is easier to manage the process of sending a file to the backend.
For cases when graphql is used as a transport instead of rest.
For cases when it is more convenient to use your api layer than to adjust to your api.
Something like that

  {
    handlers: {
      byFile (file, done) {
        /// magic code
        done(url)
      },
      byUrl (url, done) {
        /// magic code
        done(urlFromBackend)
      },
    },
  }

// or promise
{
      handlers: {
        async byFile (file) {
          // magic code
          return url;
        },
        async byUrl (url) {
          // magic code
          return urlFromBackend;
        },
      },
}

Alt tag

Im working a couple off days now with the editor which works beautiful! But after some times a online content creator pointed out to me that is not possible to add alt tags to the image. Is this something which is on the roadmap?

Unable to find URL in request (nodejs)

I am trying to upload image by URL but when I paste valid URL with image extensions like ( jpg/jpeg), I cannot find that same url anywhere in my req object. Uploads by file is working fine but when uploading by url , I am having this issue.

router.post('/fetchUrl', (req,res) => {
// console.log(Object.keys(req))
console.log(req.body) // undefined
console.log(req.params) //{ }
console.log(req.query) //{ }
})
//My post routers
router.post('/uploadImage', upload.single('image') , async (req,res) => {
const image = new Image({image: req.file.buffer})
await image.save()
const uploaderRes = {
success: 1,
file: {
url:'http://localhost:3000/' + image._id + '/image'
}
}
res.send(uploaderRes)
})

router.post('/fetchUrl', (req,res) => {
console.log(req.body)
})

//My Editor instance
const editor = new EditorJS({
holder: 'editorjs',

tools: {
    header: {
        class: Header,
        inlineToolbar: ['link']
    },
    list:{
        class: List,
        inlineToolbar: true
    },
    embed:{ 
        class: Embed,
        inlineToolbar: false,
        config:{
            services: {
                youtube: true,
                coub: true,
            }
        }
    },
    image: {
        class: ImageTool,
        config: {
            endpoints: {
                byFile: '/uploadImage', 
                byUrl: '/fetchbyurl',                
            }
        }
    }
}

})

"npm run build" errors

editor.js\example\tools\image>npm run build

ERROR in ./src/index.js
Module build failed (from ./node_modules/eslint-loader/index.js):
Error: ESLint configuration in C:\Users\q4rockz\Documents\GitHub\editor.js\example\tools\image\node_modules\eslint-config-codex\configs\ts.json is invalid:
- Unexpected top-level property "overrides[0].extends".

Referenced from: C:\Users\q4rockz\Documents\GitHub\editor.js\example\tools\image\node_modules\eslint-config-codex\index.js
Referenced from: C:\Users\q4rockz\Documents\GitHub\editor.js\example\tools\image.eslintrc
at validateConfigSchema (C:\Users\q4rockz\Documents\GitHub\editor.js\example\tools\image\node_modules\eslint\lib\config\config-validator.js:235:15)
at Object.validate (C:\Users\q4rockz\Documents\GitHub\editor.js\example\tools\image\node_modules\eslint\lib\config\config-validator.js:261:5)
at loadFromDisk (C:\Users\q4rockz\Documents\GitHub\editor.js\example\tools\image\node_modules\eslint\lib\config\config-file.js:544:19)
at load (C:\Users\q4rockz\Documents\GitHub\editor.js\example\tools\image\node_modules\eslint\lib\config\config-file.js:587:20)
at C:\Users\q4rockz\Documents\GitHub\editor.js\example\tools\image\node_modules\eslint\lib\config\config-file.js:453:36
at Array.reduceRight ()
at applyExtends (C:\Users\q4rockz\Documents\GitHub\editor.js\example\tools\image\node_modules\eslint\lib\config\config-file.js:431:26)
at loadFromDisk (C:\Users\q4rockz\Documents\GitHub\editor.js\example\tools\image\node_modules\eslint\lib\config\config-file.js:551:22)
at load (C:\Users\q4rockz\Documents\GitHub\editor.js\example\tools\image\node_modules\eslint\lib\config\config-file.js:587:20)
at C:\Users\q4rockz\Documents\GitHub\editor.js\example\tools\image\node_modules\eslint\lib\config\config-file.js:453:36
at Array.reduceRight ()
at applyExtends (C:\Users\q4rockz\Documents\GitHub\editor.js\example\tools\image\node_modules\eslint\lib\config\config-file.js:431:26)
at loadFromDisk (C:\Users\q4rockz\Documents\GitHub\editor.js\example\tools\image\node_modules\eslint\lib\config\config-file.js:551:22)
at Object.load (C:\Users\q4rockz\Documents\GitHub\editor.js\example\tools\image\node_modules\eslint\lib\config\config-file.js:587:20)
at Config.getLocalConfigHierarchy (C:\Users\q4rockz\Documents\GitHub\editor.js\example\tools\image\node_modules\eslint\lib\config.js:240:44)
at Config.getConfigHierarchy (C:\Users\q4rockz\Documents\GitHub\editor.js\example\tools\image\node_modules\eslint\lib\config.js:192:43)
at Config.getConfigVector (C:\Users\q4rockz\Documents\GitHub\editor.js\example\tools\image\node_modules\eslint\lib\config.js:299:21)
at Config.getConfig (C:\Users\q4rockz\Documents\GitHub\editor.js\example\tools\image\node_modules\eslint\lib\config.js:342:29)
at processText (C:\Users\q4rockz\Documents\GitHub\editor.js\example\tools\image\node_modules\eslint\lib\cli-engine.js:181:33)
at CLIEngine.executeOnText (C:\Users\q4rockz\Documents\GitHub\editor.js\example\tools\image\node_modules\eslint\lib\cli-engine.js:690:40)
at lint (C:\Users\q4rockz\Documents\GitHub\editor.js\example\tools\image\node_modules\eslint-loader\index.js:278:17)
at Object.module.exports (C:\Users\q4rockz\Documents\GitHub\editor.js\example\tools\image\node_modules\eslint-loader\index.js:273:21)
npm ERR! code ELIFECYCLE
npm ERR! errno 2
npm ERR! @editorjs/[email protected] build: webpack --mode production
npm ERR! Exit status 2
npm ERR!
npm ERR! Failed at the @editorjs/[email protected] build script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\q4rockz\AppData\Roaming\npm-cache_logs\2020-04-22T04_05_42_945Z-debug.log

Disable Settings (caption, withBorder, withBackground, stretched)

I am new to Editor.js and not sure if this is plugin-specific or not. Is it possible to disable specific settings (caption, withBorder, withBackground, stretched) or disable settings at all? I don't need a background variant, so the user shouldn't be able to choose it in the first place.

Thank you very much, I appreciate your work!

Unselected image doesn't provide URL parameter, causing an error when validating the blocks.

When saving the blocks, the image block without a selected image doesn't provide an URL parameter under file. When an image is selected, it does. With the URL parameter the validator configuration for the image looks something like this:

{
"tools": {
  "image": {
    "caption": {
      "type": "string"
    },
    "file": {
      "type": "array",
      "data": {
        "url": "string"
      }
    },
    "stretched": {
      "type": "bool",
      "canBeOnly": [false]
    },
    "withBackground": {
      "type": "bool",
      "canBeOnly": [false]
    },
    "withBorder": {
      "type": "bool",
      "canBeOnly": [false]
    }
  }
}
}

And this configuration works fine if an image is selected. The save data should look something like this:

{
  "type": "image",
  "data": {
    "file": {
      "url": "uploads/image14.png"
    },
    "caption": "This is the 14th image",
    "withBorder": false,
    "stretched": false,
    "withBackground": false
  }
}

Unfortunately, when an image isn't selected, the block returns the save data without url parameter, like this:

{
  "type": "image",
  "data": {
    "file": {},
    "caption": "",
    "withBorder": false,
    "stretched": false,
    "withBackground": false
  }
}

This causes the following error with my validator-configuration:

PHP Fatal error:  Uncaught EditorJS\EditorJSException: Not found required param `url` in /path/tp/project/vendor/codex-team/editor.js/EditorJS/BlockHandler.php:96
Stack trace:
#0 /path/tp/project/vendor/codex-team/editor.js/EditorJS/BlockHandler.php(157): EditorJS\BlockHandler->validate(Array, Array)
#1 /path/tp/project/vendor/codex-team/editor.js/EditorJS/BlockHandler.php(55): EditorJS\BlockHandler->validate(Array, Array)
#2 /path/tp/project/vendor/codex-team/editor.js/EditorJS/EditorJS.php(126): EditorJS\BlockHandler->validateBlock('image', Array)
#3 /path/tp/project/vendor/codex-team/editor.js/EditorJS/EditorJS.php(96): EditorJS\EditorJS->validateBlocks()
#4 /path/tp/project/editor/uploadArticleData.php(184): EditorJS\EditorJS->__construct('{"time":1581957...', '{\n"tools": {\n\t"...')
#5 {main}
  thrown in /path/tp/project/vendor/codex-team/editor.js/EditorJS/BlockHandler.php on line 96

If I missed something and this is intended behavior, please tell me what I did wrong and how I can fix it. If not, please look into this. Both ways, I thank you for creating this plugin and that you took your time to read my issue.

Sincerely,
Alexander Horner

Store locally with PouchDB

Hi There,

I'm trying to store the image locally with pouchDB, which is working, but I can't find a way to retrieve the image from the db, there is no 'url' just an id.

Where is the logic which actually loads the image? If I can override that i'll be fine.

Thanks for a great plugin!

Rotate image

When is this feature due? Or does anyone have tips how to implement this feature myself?

Unable to upload image

The icon for the image appears just fine but I get a warning that the image cannot be uploaded. Right now I'm testing on a dev environment and cannot connect to a live server to upload the image.

The problem still happens when I don't pass a config object. Is there a way to test with mock endpoints that will work?

This is my current config for that tool:

image: {
          class: ImageTool,
          config: {
            endpoints: {
              byFile: "http://localhost:3000/uploadFile",
              byUrl: "http://localhost:3000/fetchUrl"
            }
          }
        }

and this is the error I get in the console.

body: "<!DOCTYPE html>\n<html lang=\"en\">\n<head>\n<meta charset=\"utf-8\">\n<title>Error</title>\n</head>\n<body>\n<pre>Cannot POST /uploadFile</pre>\n</body>\n</html>\n"

code: 404
connection: "keep-alive"
"content-length": "150"
"content-security-policy": "default-src 'none'"
"content-type": "text/html; charset=utf-8"
date: "Thu, 27 Feb 2020 17:01:06 GMT"
vary: "Accept-Encoding"
"x-content-type-options": "nosniff"
"x-powered-by": "Express"

Can't get the caption and the image styles from response

It seems it doesn't get neither the caption nor the image style properties (stretched, withBackground, withBorder) that I'm passing with the response.

This is the code of my response.

   return response()->json([

        "success" => 1,

        "file" => [

            "url" => "http://localhost:8000/storage/rte-images/" . $cleanedFilenameWithExtension
        ],

        "caption" => "this is the caption",

        "withBorder" => false,

        "withBackground" => false,

        "stretched" => true

    ]);`

When I look into the outputData, the caption is always an empty string and the image properties (stretched, withBackground, withBorder) are all false.

"false" being treated as true instead of false in block tunes

It looks like blocktunes for this plugin are being treated as truthy when their values are set to the string "false".

It looks like this line is probably the culprit:

const value = data[tune] !== undefined ? data[tune] : false;

Sample data to reproduce:

const data = {
  "time": "1566499088222",
  "blocks": [
    {
      "type": "image",
      "data": {
        "file": {
          "url": "/path/to/file"
        },
        "caption": "...",
        "withBorder": "false", // these are treated as true by the plugin
        "stretched": "false",
        "withBackground": "false"
      }
    },
    {
      "type": "image",
      "data": {
        "file": {
          "url": "/path/to/file/2"
        },
        "caption": "...",
        "withBorder": false, // these are treated as false
        "stretched": false,
        "withBackground": false
      }
    },
    {
      "type": "image",
      "data": {
        "file": {
          "url": "/path/to/file/3"
        },
        "caption": "...",
        "withBorder": true, // these are treated as true and false correctly
        "stretched": false,
        "withBackground": false
      }
    },
  ],
  "version": "2.15.0"
};

Not getting the file object while using custom uploader.

I am trying to use custom uploader, specifically uploadByFile method. This method takes one argument, which is supposed to be the file that we need to upload on the server. What I am getting isa bunch of file properties, but the actual file is missing.

Here is the reference code.

tools: {
        image: {
          class: ImageTool,
          config: {
            uploader: {
              uploadByFile(file) {
                return fetch('http://localhost:3001/api/v1/file_upload', {
                  method: 'post',
                  body: JSON.stringify{
                    file: file,
                    filename: 'first_img'
                  })
                }).then(function(response) {
                  return {
                    success: 1,
                    file: {
                      url: 'https://my-photo-gallary.s3.ap-south-1.amazonaws.com/go_that_extra_mile.png'
                    }
                  }
                })
              }
            }
          }
        }
      }

Here is what I receive when logging the file argument.

Screen Shot 2019-10-17 at 10 45 51 PM

Passing the data into editor ignore stretched image

If you want to pass the data from editor JS into the data: value of the editor config, it ignores the stretched value. Im guessing that this is an issue with the render function of this module, rather than an issue with the main editor JS API

See CodePen: https://codepen.io/MrSimmons/pen/QWWYVvy
If you change the boolean of stretched in the data, you can see that the image doesn't resize in the editor. the image in the editor only resizes when you then toggle the stretched value off then on again in the editor.

Where is the file data during request to server?

Good day guys,

I have a summary of my concern below

const EDITOR_JS_TOOLS = {
    image: {
        class: Image,
        config: {
            endpoints: {
                byFile: 'http://localhost:3001/api/uploads'
            },
            field: 'image',
            types: 'image/*'
        }
    }
}

const CommentEditor = () => {
    return <EditorJs tools={EDITOR_JS_TOOLS} />
}

When my react sends request to

router.post('/', async (req, res) => {
//when client use this endpoint, console.log can display a message
})

but where is the data?
I look it to req.body but empty

Thank you.

Same Image gets rendered into all the proceeding image blocks.

I am trying to upload an image using the config.endpoints function. The very first image I upload is correct, but rest other images following it are the same as the first one. Although, the back end is returning correct URL for the newly update image.

My configuration is as follows -

tools: {
        image: {
          class: ImageTool,
          config: {
            endpoints: {
              byFile: 'http://localhost:3001/api/v1/file_upload'
            },
            field: 'file',
            types: 'image/*',
          }
        }

The plugin is not rendering the <img> tag after upload

Hi,

I configured the image plugig and it's partially working. Basically after I upload an image, I get a never ending loader without the tag with the url being created.

this is the image tool config:

`image: {
      class: ImageTool,
           config: {
                endpoints: {
                     byFile: '/api/images/image-handler' + '?api_token=' + this.isLogged.apiToken,
                }
           }
 }`

This is the response from the backend (static url just for the example)

`return response()->json([
        "success" => 1,
        "file" => "http://localhost:8000/storage/rte-images/rose-small.jpg",
 ]);`

and this is the outputData that I'm console logging onChange

{ file: "http://localhost:8000/storage/rte-images/rose-small.jpg", caption: "", withBorder: false, stretched: false, withBackground: false }

It's all correct. The image is properly added to the JSON with the url I'm passing in the response. And I get no errors of any kind. So it's actually working except for the fact that the image preloader keeps spinning forever and no tag is added.

Maybe I miss something?

Image uploaded, no message error, but image doesn't show up

Hi, this is my current configuration for the tool:

        image: {
            class: ImageTool,
            config: {
                endpoints: {
                    byFile: '/site_content/uploadFile.php',
                    byUrl: '/site_content/fetchUrl.php'
                }
            }
        }

and my uploadFile.php returns:

{ "success": 1, "file": "https://mywebsite.com/static/uploads/image_name.png" }

The generated url is correct, when i paste it in the browser the image does show up
but still the preloader is turning and no image appears:
image

Why is this happening? Is there a secret step I missed?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.