-
AuthorPosts
-
February 19, 2016 at 4:12 am #803042
Hi,
I’ve noticed that the fallback image only seems to work on product pages and not category/search pages.
I have changed the fallback by adding some code to the function.php, but with or without this it makes no difference. The code i’m using is:
add_action( ‘init’, ‘custom_fix_thumbnail’ );
function custom_fix_thumbnail() {
add_filter(‘woocommerce_placeholder_img_src’, ‘custom_woocommerce_placeholder_img_src’);function custom_woocommerce_placeholder_img_src( $src ) {
$uploads = untrailingslashit( $upload_dir[‘baseurl’] );
$src = $uploads . ‘http://emresolutions.com.gridhosted.co.uk/product-images/no-image.png’;return $src;
}
}Thanks
February 19, 2016 at 3:53 pm #803805Hi Alex,
Would you mind providing us with login credentials so we can take a closer look? To do this, you can make a post with the following info:
– Link to your site
– WordPress Admin username / password
– FTP credentialsDon’t forget to select Set as private reply. This ensures your information is only visible to our staff.
February 27, 2016 at 3:23 am #814525This reply has been marked as private.February 27, 2016 at 9:43 am #814728Hi There,
Please delete your code and try with this instead:
add_action( 'init', 'x_custom_fix_thumbnail' ); function x_custom_fix_thumbnail() { add_filter( 'woocommerce_placeholder_img_src', 'custom_woocommerce_placeholder_img_src' ); add_filter( 'post_thumbnail_html', 'default_woo_img', 20, 2 ); function default_woo_img($html, $product_id){ $post_type = get_post_type( get_post( $product_id ) ); if( $post_type == "product" && !has_post_thumbnail($product_id) ){ $upload_dir = wp_upload_dir(); $uploads = untrailingslashit( $upload_dir['baseurl'] ); $src = 'http://emresolutions.com.gridhosted.co.uk/product-images/no-image.png'; return '<img src="'.$src.'" />'; } else { return $html; } } function custom_woocommerce_placeholder_img_src( $src ) { $src = 'http://emresolutions.com.gridhosted.co.uk/product-images/no-image.png'; return $src; } }
Hope it helps 🙂
-
AuthorPosts