I have created custom image attribute. This is displaying perfect. But when i save category, it is not saving. Images are uploading perfectly, Saving at /media/tmp, but not saving in media/catalog after saving category magento 2.

  • When you upload image, it showing preview before save ? – Suresh Chikani Oct 7 '16 at 7:40
  • Did you ever solve this? I just ran into this problem with a custom module. – LM_Fielding Jul 17 '17 at 10:45

Magento2.1 Category image upload showing preview after upload image but not working after save category.

this is magento version default bug.

To solve this issue by apply bellow patch.

Opne this url : https://github.com/magento/magento2/pull/5978/files

You have to override below core files code with file code from given URL.


Now magento-2.1 working code for custom image attribute of category.

See complete answer for the issue : See my complete answer

Let me know if you have any query/concern from above.

  • This is still not working – Sagar Dobariya Oct 7 '16 at 12:26
  • You can get reference from given my answer otherwise you have add your code so i can debug on that. – Suresh Chikani Oct 7 '16 at 13:04

I solved this issue by setting the backend_model for my attribute in the eav_attribute table to Magento\Catalog\Model\Category\Attribute\Backend\Image

When a category is saved in Magento 2 it walks through the attributes calling the afterSave function of each attribute.

As you can see below the function Magento\Catalog\Model\Category\Attribute\Backend\Image::afterSave moves the file from the tmp folder to correct folder.

public function afterSave($object)
    $image = $object->getData($this->getAttribute()->getName(), null);

    if ($image !== null) {
        try {
        } catch (\Exception $e) {
    return $this;
  • this fails in \Magento\Catalog\Model\ImageUploader::moveFileFromTmp as the $baseTmpImagePath contains both $basePath and $baseTmpPath => the copyFile method fails – Radu Apr 14 '20 at 8:53

Check if you have created a preference for Magento\Catalog\Model\Category\DataProvider, and your new DataProvider has this code in it.

class DataProvider extends \Magento\Catalog\Model\Category\DataProvider {

protected function getFieldsMap()
    $fields = parent::getFieldsMap();
    $fields['content'][] = 'custom_attribute_name';
    return $fields;
  • can i override for invoice abstactpdf.php file ? – Rv Singh Oct 26 '18 at 6:31
  • You can override only the public methods of AbstractPdf.php For protected methods, you can override the methods from where these methods are called. For example to override the method called insertLogo, override the Invoice.php which is calling insertLogo in getPdf method. – Prachi Saxena Oct 29 '18 at 4:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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