Magento 2 Cannot Import Product Images: Reasons & Resolutions

- Fire development, Magento 2

Magento 2 export CLI

In the article below, we explain two mistakes common for the import of product images to Magento 2 that roil the entire data transfer. You will find out how to counteract them, preventing possible troubles. Besides, we describe an alternative solution that reinforces the default data transfer routine, drastically extending the default import/export capabilities of the platform. More useful tips are listed here: Magento 2 Cookbook.

The Issue

Justin Blayney pointed out a problem he faced while importing products with the help of the built-in CSV tool. All the data was correctly transferred to Magento 2 except product images. Justin stuck with the following error:

The author tried several base_image paths, but nothing happened. He also checked permissions, updated PHP, and broke the whole site in his attempts to address the challenge. However, the truth was out there.  

It was necessary to specify a correct file path. In the first attempt to import product image to Magento 2, Justin relied on the following construction:

Since it became the culprit of the broken import, the author removed the existing folder structure, attempting to attain the complete transfer. After editing the CSV with the new file path, he achieved the same result.

Next, Justin Decided to reduce the complexity of the path, providing only its part:

This decision only exacerbated the problem: the new “solution” didn’t let him pass the data validator check.

The author gave up the attempt to manage the product import to Magento 2 all alone and came to StackExchange seeking advice. Justin was wondering what he did wrong and whether it was possible to import images to Magento 2 from an external server. 

The Solution

Mukesh, another StackExchange user, faced the same problem. His initial path looked as follows:

However, the author efficiently fixed the issue by reducing the complexity of the specified data. Instead of providing the image file directory, which was /pub/media/import, combined with a file name, he cut the path to the following format:

As you can see, it contains only the name of a file. As for the Images File Directory value, it is specified separately as pub/media/import in the corresponding field of the Magento 2 import tool:

These enhancements fixed the existing challenges. Therefore, let’s summarize what we know about common issues that impede the standard product image import to Magento 2. You should avoid the following two mistakes:

  • Incorrect file path;
  • Unsupported file directory.

While Justin’s desire to manage product image import to Magento 2 was satisfied, the question regarding external file sources was still unanswered. However, we know a reliable alternative solution that substantially exceeds the existing boundaries of the default import tool.

The Better Way

As Magento 2 specialists, we’ve been exploring the ecosystem since its very beginning. Right from start, it was among the most viable e-commerce solutions. However, numerous constraints didn’t let its users manage chores most efficiently. And import processes were among the notorious bottlenecks. 

When we faced the default data transfer solution for the first time, it was decided to create our alternative. Thus, the idea to develop the Improved Import and Export extension was born. How does the module help to answer the question above? 

It allows importing product images from literally anywhere, not only your local server. With the Improved Import & Export Magento 2 extension, you can transfer visual content from a remote server, Dropbox account, or URL. Furthermore, all product data can be stored in Google Sheets. And alternatively, the plugin allows you to establish an API connection with any external system so that product images can be easily imported from every possible storage.

It is also necessary to mention that unlike the default import solution, our extension supports a bunch of file formats, including CSV, XML, JSON, and ODS. Besides, you can automate data transfers using schedules and apply dozens of other enhancements, but let’s return to our mutton. 

When you import product images with the Improved Import & Export Magento 2 extension, a path to the directory must be specified in the image-related attributes of a data file. You can use special characters in the image name. Below, you can see an example of a link to an image stored externally: 

An import profile that lets you transfer product images looks as follows:

Also, note that the Improved Import & Export Magento 2 module supports YouTube and Vimeo URLs as product image attributes. Therefore, you may freely move videos to your product pages. Follow the links below to discover more features of our plugin. 

Get Improved Import & Export Magento 2 Extension

Extension Manual

How to Import Product Images