Skip to content

Commit dcb6499

Browse files
author
Hayder Sharhan
committed
MAGETWO-52993: [Github] Media Uploader Issues #2958
- Error will now be displayed to user that format is not supported..
1 parent 04795a6 commit dcb6499

File tree

3 files changed

+26
-2
lines changed

3 files changed

+26
-2
lines changed

app/code/Magento/Cms/Controller/Adminhtml/Wysiwyg/Images/Upload.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ public function execute()
3939
$targetPath = $this->getStorage()->getSession()->getCurrentPath();
4040
$result = $this->getStorage()->uploadFile($targetPath, $this->getRequest()->getParam('type'));
4141
} catch (\Exception $e) {
42-
$result = ['error' => $e->getMessage(), 'errorcode' => $e->getCode()];
42+
$result = ['error' => true, 'message' => $e->getMessage()];
4343
}
4444
/** @var \Magento\Framework\Controller\Result\Json $resultJson */
4545
$resultJson = $this->resultJsonFactory->create();

lib/web/mage/loader.js

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ define([
178178
.addClass(this.options.loadingClass)
179179
.attr({
180180
'aria-busy': true
181-
})
181+
});
182182

183183
if (settings && settings.showLoader) {
184184
var ctx = this._getJqueryObj(settings.loaderContext);
@@ -201,6 +201,18 @@ define([
201201
if (settings && settings.showLoader) {
202202
this._getJqueryObj(settings.loaderContext).trigger('processStop');
203203
}
204+
205+
if (jqxhr.responseJSON && jqxhr.responseJSON.error) {
206+
var tempErrorMessage = document.createElement("div");
207+
tempErrorMessage.className = "message message-warning warning";
208+
tempErrorMessage.innerHTML = JSON.parse(jqxhr.responseText).message;
209+
210+
tempErrorMessage.addEventListener("click", function () {
211+
tempErrorMessage.remove();
212+
}, false);
213+
214+
document.querySelector("#content_header").appendChild(tempErrorMessage);
215+
}
204216
}
205217

206218
});

lib/web/mage/loader_old.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,18 @@
197197
if (settings && settings.showLoader && !settings.dontHide) {
198198
this._getJqueryObj(settings.loaderContext).trigger('processStop');
199199
}
200+
201+
if (jqxhr.responseJSON && jqxhr.responseJSON.error) {
202+
var tempErrorMessage = document.createElement("div");
203+
tempErrorMessage.className = "message message-warning warning";
204+
tempErrorMessage.innerHTML = JSON.parse(jqxhr.responseText).message;
205+
206+
tempErrorMessage.addEventListener("click", function () {
207+
tempErrorMessage.remove();
208+
}, false);
209+
210+
document.querySelector("#content_header").appendChild(tempErrorMessage);
211+
}
200212
}
201213
});
202214

0 commit comments

Comments
 (0)