I am running Magento 2.2.3

When I try and go to admin/catalog/category/ and select a category it just spins and I get this javascript error.

Uncaught TypeError: value.map is not a function
at UiClass.setInitialValue (file-uploader.js:74)
at UiClass.initialize (abstract.js:73)
at UiClass.initialize (wrapper.js:109)
at new UiClass (class.js:49)
at Object.initComponent (layout.js:137)
at fire (jquery.js:3232)
at Object.fireWith [as resolveWith] (jquery.js:3362)
at Object.deferred.(/admin_1u9idw/catalog/category/edit/key/6bfefd3ede425d7d38ed258f6746c49ffc93015a1417f514ea0773cbf7c503ea/id/165/anonymous function) (http://magento.local/static/version1524775074/adminhtml/Magento/backend/en_US/jquery.js:3461:37)
at fire (jquery.js:3232)
at Object.fireWith [as resolveWith] (jquery.js:3362)

file-uploader.js is a core file I believe, and I have never touched it.

This is the code in the file that is giving me the error-

     * Defines initial value of the instance.
     * @returns {FileUploader} Chainable.
    setInitialValue: function () {
        var value = this.getInitialValue();

        value = value.map(this.processFile, this);

        this.initialValue = value.slice();

        this.on('value', this.onUpdate.bind(this));

        return this;

Specifically this line- value = value.map(this.processFile, this);

This is all core Magento and I have never touched any of the code. I have done the standard clear cache, clear browser, deploy static content, reindex, and remove static files.

I have made a child theme off the blank theme.

  • 1
    What format of image are you uploading ? Commented Jul 26, 2018 at 21:14
  • Is it working fine for product image upload? Commented Jul 26, 2018 at 21:14
  • @VivekKumar just checked. I tried both png and jpg, same result. Product image upload works fine.
    – tjjen
    Commented Jul 26, 2018 at 21:19
  • so .. the error is happening for only categories, is it happening for a specific category? Commented Jul 26, 2018 at 21:21
  • All categories that were migrated from Magento 1. If it was created in Magento 2 it works fine.
    – tjjen
    Commented Jul 26, 2018 at 21:23

3 Answers 3


If anyone is coming here because you are creating a custom fileUploader element. Your data has to be an array of arrays. The fileUploader expects multiple files.

I changed my image_value to an array when loading the data.

$item->setData("image_value", [[$item->getData("image_value")]]);
  • Brilliant finding Paul, was pulling my hair out for hours,... thank you very much. Commented Jun 25, 2020 at 20:05
  • 1
    Any idea how to fix when using uiComponents ?
    – Badong
    Commented Jul 24, 2020 at 11:55
  • Perfect! Should be marked as solution.
    – Sumit
    Commented Aug 19, 2020 at 4:25

For anyone struggling with what I had: to render the image after saving the image, the UI component needs an array to be passed back to it. For me I had to create: [Vendor]\[Module]\Ui\DataProvider\[element]\Form\Modifier\[element]Data.php (for example if your element is "Store" it will be StoreData.php. The contents of your [element]Data file should be:

namespace [Vendor]\[Module]\Ui\DataProvider\[element]\Form\Modifier;

use Magento\Ui\DataProvider\Modifier\ModifierInterface;
use [Vendor]\[Module]\Model\ResourceModel\[element]\CollectionFactory;

class [element]Data implements ModifierInterface
     * @var \[Vendor]\[Module]\Model\ResourceModel\[element]\Collection
    protected $collection;

     * @param CollectionFactory $CollectionFactory
    public function __construct(
        CollectionFactory $CollectionFactory
    ) {
        $this->collection = $CollectionFactory->create();

     * @param array $meta
     * @return array
    public function modifyMeta(array $meta)
        return $meta;

     * @param array $data
     * @return array|mixed
     * @throws \Magento\Framework\Exception\LocalizedException
    public function modifyData(array $data)
        $items = $this->collection->getItems();
        foreach ($items as $element) {
            $_data = $element->getData();
            if (isset($_data['image'])) { //have a look in $_data to make sure "image" is the index you want.
                $image = [];
                $image[0]['name'] = $element->getImage();
                $image[0]['url'] = $element->getImageUrl($image[0]['name']);
                $_data['image'] = $image;
            $data[$element->getId()] = $_data;
        return $data;

And then in your di.xml, you need something like this:

<virtualType name="{your modifier pool name, i've called mine VendorModuleUiElementFormModifierPool" type="Magento\Ui\DataProvider\Modifier\Pool">
        <argument name="modifiers" xsi:type="array">
            <item name="[element]_data" xsi:type="array">
                <item name="class" xsi:type="string">[vendor]\[Module]\Ui\[Element]\Form\Modifier\[element]Data</item>

Essentially whatever your data provider is for your form page, make sure the data being provided for your image uploader is an array. The code for this is

        $image = $element->getImage();
        if (isset($image)) {
            $image = [];
            $image[0]['name'] = $element->getImage();
            $image[0]['url'] = $element->getImageUrl();
  • 1
    What is "location_data" in your di.xml ? Commented Jun 4, 2021 at 11:50
  • 1
    @ChristopheFerreboeuf really good spot, thank you. It should have been written [element]_data instead. location was the element I was working on at the time.
    – John
    Commented Jun 9, 2021 at 6:46

The problem is with Amasty Layered Navigation. If that is disabled everything works fine.

  • 1
    This cannot be the accepted answer - even in your question you mention that it's "all core magento" Commented Dec 13, 2021 at 14:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.