Asset Manager not automatically add images to assets after uploading
Question
The JSON response of an upload is like this {"data":["http://url.com/flower.jpg"]}
The response event is working.In the response event response is in the format of string. Content-type is set to application/json when uploaded file.
Now I manually add image to assets in the response event. Is there any problem in the response format I get after a file upload?
Answers (3)
I have the same problem and like you i added the files manually. just in case someone else looks at this and needs to achieve the same thing manually
editor.on('asset:upload:response', (response) => {
var result = JSON.parse(response);
editor.AssetManager.add(result.data);
});
var result = JSON.parse(response);
editor.AssetManager.add(result.data);
});
my response looks like this
{"data":[{"type":"image","height":100,"width":100,"src":"https://www.sunzu.com/updated/cdn/696567-ea0401d4141da8ee123e8c76aa1483b955b74110.jpg"}]}
@artf i believe the issue here is inside src\asset_manager\view\FileUploader.js you have on line 77 inside onUploadResponse(text)
const json = typeof text === 'text' ? JSON.parse(text) : text;
this should be
const json = typeof text === 'string' ? JSON.parse(text) : text;
typeof text === 'text'
LOL Yeah I'd say it's definitely the reason behind the bug Would you like to PR it? :)
@artf thanks i have sent a PR
Related Questions and Answers
Continue research with similar issue discussions.
Issue #646
Images dropped onto image picker get uploaded twice
Set the asset manager with the dropzone option set to true (which is true by default), something like that: then drop an image onto the dro...
Issue #1816
Not allowing to upload same image on same the position after delete that image
Ajax call which is uploading image file in assests folder It's working fine to add an image from the local. But in another scenario, It's n...
Issue #401
Cannot upload images
Hi, while uploading an image through asset manager, I get the following error: Assetmanager configuration at editor init looks like Folder...
Issue #930
[Question] Update resizer after asset changed
Hi! I trying to change default assets manager with ours custom manager. On double click the selected image is replaced with a new one with...
Paid Plugins That Match This Issue
Curated by issue keywords and label relevance to help you ship faster.
Loading paid plugin recommendations...
Browse Plugin Categories
Jump directly to plugin category pages on the marketplace.