Import larger product images

Some merchants provide a larger version of their images in other fields than the image field. This tutorial explains how you can import those large images instead of the smaller ones if the larger ones are available.

Important!

If you have already imported products which have small images, the tutorial below will not replace the small images with the larger images. You will first need to update the Product Sets responsible for adding those products with small images and then delete those small images from your already imported products. You can "Bulk Delete" images here: WordPress Admin Area > Media.

1

Identify the field with a larger image

First you will need to identify the alternative field you want to use in place of the default image field. You can see all of the available fields for a product by clicking the product's name and then viewing the list of fields. In the screenshot below, this merchant has another field named largeimage which contains a larger version of the product image.

An example of a product which has a field containing a larger version of the product image
2

Create a custom plugin

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

3

Add custom code

Add the following code to your custom plugin file.

/**
 * Use the most desired image field.
 */
add_filter( 'dfrpswc_filter_postmeta_array', 'mycode_use_different_image_field', 20, 5 );
function mycode_use_different_image_field( $meta, $post, $product, $set, $action ) {

	/**
	 * An array of fields in the order in which you want to choose them.
	 * You can add more fields to this list but do not remove the 'image'
	 * field and do not change its position. It should always be last.
	 */
	$image_fields = array(
		'largeimage',       // Use the 'largeimage' field if it exists.
		'merchantimageurl', // Use the 'merchantimageurl' field if it exists.
		'image',            // Do not remove this line.
	);

	// Loop thru fields in order of usage preference.
	foreach ( $image_fields as $field ) {
		if ( isset( $product[ $field ] ) ) {
			$meta['_dfrps_featured_image_url'] = $product[ $field ];
			break;
		}
	}

	return $meta;
}
	
4

Add your targetted image fields

Add to or modify the $image_fields array to target fewer, more or different image fields. (line #13 - #14). Do not remove the last item named image from the $image_fields array.

5

Save

Save your custom plugin file.

6

Add new Product Sets

These changes will only take effect after any new Product Sets are created.

Still need help? Contact Us Contact Us