javafiend
Forum Replies Created
Viewing 4 replies - 1 through 4 (of 4 total)
-
Thanks! With all of their rules, I just wanted to make sure I was in compliance.
Forum: Plugins
In reply to: [WooCommerce] Link Single Product Image to Affiliate LinkHere is an inelegant solution that is based on Sadoo’s solution from 2016 (here is the link if interested: Woocommerce – external/affiliate product image to external link (buy URL)
add_filter('woocommerce_single_product_image_thumbnail_html', 'change_product_image_link', 10, 2); function change_product_image_link( $html, $thumbnail_id) { $post = get_post(); $product = wc_get_product( $post->ID ); if ( is_product() ){ $props = wc_get_product_attachment_props(get_post_thumbnail_id(), $post); $image = '<div class="woocommerce-product-gallery__image--placeholder">'; $image .= sprintf( '<img src="%s" alt="%s" title="%s" class="wp-post-image" />', esc_url( get_the_post_thumbnail_url($post_thumbnail_id,'full') ), $props['alt'], $props['title'] ); $image .= '</div>'; $out = sprintf( '<a href="%s" itemprop="image" class="woocommerce-main-image zoom" title="%s">%s</a>', $product->get_product_url(), esc_attr($props['caption']), $image); return $out; } else { return $html; } }
Like I said, it’s not elegant. So, please feel free to submit a more complete solution.
Awesome, thanks!
Thanks. I ended up finding that last night right after I posted.
Are there any plans to add that as a feature in the Settings at some point?
Viewing 4 replies - 1 through 4 (of 4 total)