• Resolved beantown123

    (@beantown123)


    Hi, I am close to solving an issue I had with your plugin that could help other users.

    My goal is only to share specific images on my site instead of all images.

    Solution I didn’t want to use: I read through the forums and it was recommended to put my chosen images in their own directory, but I didn’t want to change the URL of the images.

    I was able to solve the issue for one specific image and used the following code using its wordpress image id:

    a2a_config.overlays.push({
    target: ‘img.wp-image-fill in wordpress image id’,
    services: [‘pinterest’, ‘facebook’, ‘twitter’]
    });

    However, I didn’t know how to make work with multiple images. I tried using the && or || operators, but it doesn’t seem to work for both images.

    A few questions:
    1. Any ideas to solve?
    2. Could this increase the load on my site if it has to check every image to match the specific ID?
    3. On an unrelated note, do you have an instagram share option?

    Thanks.

Viewing 5 replies - 1 through 5 (of 5 total)
  • Thread Starter beantown123

    (@beantown123)

    Actually one thing I have noticed is that when I try to share the image, Facebook shares a different image on the page with the article. Same thing with twitter. Is this supposed to share the infographic or the article itself?

    Plugin Author micropat

    (@micropat)

    1. Use CSS selectors to match class names that begin with wp-image-:

    a2a_config.overlays.push({
        target: 'img[class^="wp-image-"], img[class*=" wp-image-"]',
        services: ['pinterest', 'facebook']
    });

    2. The load on the site doesn’t change, and web browsers handle this performantly.

    3. See the plugin’s FAQ: Where are buttons such as Instagram, YouTube, Snapchat?

    Regarding Facebook image sharing, Facebook has a recent bug* that prevents an image from being shared right now, so a page is shared instead of an image currently. It’s up to Facebook to fix this.

    Twitter’s sharing endpoint doesn’t accept arbitrary images, unlike the few major services that accept arbitrary images in sharing: Pinterest, Facebook*, Houzz, Tumblr. You can implement Twitter Card meta tags to choose the image preview that appears in tweets when a page is shared.

    Thread Starter beantown123

    (@beantown123)

    Hi thank you for the detailed reply. I want to make sure I understand. By matching class names with wp-image-, wouldn’t this share all images on my wordpress site with wp-image? Basically I have lots of images on the site I do not need to share, but are all in the same class I believe. I just want to choose like 2 total to share.

    Plugin Author micropat

    (@micropat)

    By matching class names with wp-image-, wouldn’t this share all images on my wordpress site with wp-image-?

    Correct.

    To target specific class names such as wp-image-1 and wp-image-2, you can use multiple CSS selectors separated by a comma:

    a2a_config.overlays.push({
        target: 'img.wp-image-1, img.wp-image-2',
        services: ['pinterest', 'facebook', 'twitter']
    });
    Thread Starter beantown123

    (@beantown123)

    Thank you! I will try this out.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Sharing only specfic images- So close to solution’ is closed to new replies.