This website uses cookies to personalize your experience. By using this website you agree to our cookie policy.

Reply To: Product images are not displayed

#29863
Ernest MarcinkoErnest Marcinko
Keymaster

Hi,

On the main site, if I search star wars with the plugin disabled, I get no results: https://i.imgur.com/o4lKFJV.png
That is, because cross-multisite results are not possible to search in default WooCommerce. With the search enabled, the results will appear, but the images cannot be fetched by the theme, as they exits on a different multisite blog and the theme cannot recognize that.

If you search on the same blog, as the results are from, the images will work all right. For example searching on blog “/filmy-knihy-hry/” phrase “plagueis” will yield results with the images correctly: https://i.imgur.com/t2H4vS6.png

You can access the search images via the search plugin API theme functions, via the the_asp_result_field('image'); function.

You can try a custom code solution to automatically hook into the search result images and try a replacement, but this may cause other issues, so please make sure to carefully test it. Try adding this custom code to the functions.php in your theme/child theme directory. Before editing, please make sure to have a full site back-up just in case!

// ASP
add_filter('wp_get_attachment_image_src', 'asp_wp_get_attachment_image_src', 10, 1);
function asp_wp_get_attachment_image_src($image) {
	//var_dump($image);
	if ( !empty(get_asp_result_field('image')) )
		return array(get_asp_result_field('image'), 300, 300, true);
	else 
		return $image;
}

Once again, if this does not work, then the only solution is to edit the theme to fetch the images cross network.