I am working on magento 2 and when i try to upload a swatch attribute image but each time i get the below error. Please check the below screenshot.

enter image description here

I debug code more and found that image path error.

This is my js path : vendor/magento/module-swatches/view/adminhtml/web/js

iframeHandler = function () {
       var imageParams = $.parseJSON($(this).contents().find('body').html()),
       fullMediaUrl = imageParams['swatch_path'] + imageParams['file_path'];

imageParams['file_path'] value is undefined.

Please help me to resolve this error.

3 Answers 3


I have a solution for your issue.

It cause is the role of admin .. Please change ADMIN_RESOURCE from Magento_Swatches::iframe to Magento_Backend::admin in file Magento\Swatches\Controller\Adminhtml\Iframe\Show


I had a problem with uploading swatch image, but only on custom roles users. For admin user there is no issue. Pham thanh is in the right direction, but I think there is a better way, by just adding the missing acl in a custom modue. It has been fixed already in magento 2.2 (https://github.com/magento/magento2/commit/68a79d980dce923bcb361a18ee28e3bf6ea42f86)

If you can't upgrade to 2.2 you can create a module and just add the missing acl :

/Vendor/ModuleName/etc/acl.xml :

<?xml version="1.0"?>
 * Copyright © Magento, Inc. All rights reserved.
 * See COPYING.txt for license details.
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Acl/etc/acl.xsd">
            <resource id="Magento_Backend::admin">
                <resource id="Magento_Backend::stores">
                    <resource id="Magento_Backend::stores_attributes">
                        <resource id="Magento_Swatches::iframe" title="Swatches" translate="title" sortOrder="70" />

In my case the issue was due to using PHP 7.1. It's a Magento bug which ash been documented here https://github.com/magento/magento2/issues/11828, also you can see the fix here https://github.com/magento/magento2/commit/ee5fc2ece394318aa8f06ecaaae15ffc6dddb645

I hope it helps.

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.