Support » Plugin: AddToAny Share Buttons » Issue with Pinterest sharing on product page

  • Resolved Karen

    (@kswilfong)


    When I click the Pinterest share button, it asks which image to share and shows all images on the page (including the size chart, color chart, and all related product images). How can I have this share ONLY the current product?

    The page I need help with: [log in to see the link]

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author micropat

    (@micropat)

    There are a few ways to override Pinterest’s image picker and share a specific image.

    • Enable AddToAny image sharing for the quickest way to share a specific image. While it provides share buttons that appear on hover over images, it doesn’t override Pinterest’s picker for your other Pinterest buttons.
    • Edit your theme’s template files to add the data-pin-nopin attribute to the images you don’t want to appear in Pinterest’s picker.
    • Edit your theme’s template files to hardcode AddToAny share buttons and programmatically specify the shared image using the linkmedia parameter. Theme developers tend to prefer this method.
    • Use AddToAny events to specify the image shared to Pinterest. This can apply to all your AddToAny Pinterest buttons and is probably the best way.

    For your site, add the following code to your “Additional JavaScript” box in Settings > AddToAny:

    a2a_config.callbacks.push({
        share: function(data) {
            // Get the main product's image if present on the page
            var image = document.querySelector('.woocommerce-product-gallery img.wp-post-image');
            
            // If sharing to Pinterest and a product image is present
            if ('Pinterest' === data.service && image && image.src) {
                // Set the shared image to the product image
                return {
                    media: image.src
                };
            }
        }
    });

    Hi,

    You are sure that nothing has changed on Pinterest, when I click the Share button, I no longer see “featured Image” as before.
    https://foxdao.net/chair-de-poule-2/
    I use the plugin for 2/3 years minimum, never had this before.

    Everything is good, if I go directly to the site Pinterest, it sees well my “featured Image “.

    Thank you

Viewing 2 replies - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.