Import additional product images as gallery images

In some cases merchants provide alternative image URLs for their products. These alternative image URLs will be stored in their own fields. This tutorial explains how to import those additional product images as gallery images for the product.

For example, take a look at this product:

Product with additional image URLs

This product contains 4 additional product image URLs:

  1. alternateimage
  2. alternateimagefour
  3. alternateimagethree
  4. alternateimagetwo

Let's set up our code to import those 4 additional product images into our product image gallery so that our end result looks like this:

Example of gallery images being displayed.


Often times you might see alternate image URL fields for a product but those are just different sizes of the main image field and NOT different images. Before adding the following code to your site, be sure that the additional image URLs are actually for different images, not just the same image at different sizes. Otherwise you will spend A LOT of time deleting duplicate images from your Media Library.


Create a custom plugin

If you haven't done so already, create a custom plugin.


Add custom code

Add the following code to your custom plugin:


Edit image fields

In the above code we have customized lines 16~19 to use those specific fields. Your additional product image URLs fields may have different names. You should modify the $image_fields array to fit your needs.



Save your custom code.

Now the next time a product that contains those fields is loaded on your site, their additional product images (if they exist) will be imported into the product gallery.

Did this answer your question? Thanks for the feedback There was a problem submitting your feedback. Please try again later.

Still need help? Contact Us Contact Us