How to Customize AddToAny Image Share Button Size and Behavior
Content
Many WordPress users love the AddToAny Share Buttons plugin for its ability to add social sharing buttons directly onto images. However, a common point of confusion is how to control which images get these buttons. By default, the plugin adds share overlays to all images that are at least 200 x 200 pixels. For sites with many smaller images, like technical diagrams or employee headshots, this default can lead to buttons appearing where they aren't wanted.
Why This Happens
The 200x200 pixel minimum is a default setting designed to target generally share-worthy images. The plugin's core functionality applies this rule site-wide, which means it doesn't inherently distinguish between a featured image in a blog post and a small logo in a site's header or footer. This broad application is what often leads to share buttons appearing in undesirable locations.
Common Solutions for Customizing Image Sharing
1. Exclude Images by HTML Attribute (Quick Fix)
The simplest way to prevent buttons from appearing on a specific image is to add the data-a2a-overlay="false" attribute directly to the image's HTML <img> tag. This is a manual but effective method for one-off exclusions.
2. Use Custom JavaScript to Target Specific Images
For more control, you can use the plugin's "Additional JavaScript" setting to define exactly which images should have share buttons. This is the most powerful and common method for customization.
Example 1: Target by CSS Class
This code adds share buttons only to images with a specific class, such as share-image.
a2a_config.overlays.push({
target: 'img.share-image',
services: [ 'pinterest', 'facebook', 'twitter' ]
});
Example 2: Target by WordPress Image ID
You can target images using their unique WordPress ID class.
a2a_config.overlays.push({
target: 'img.wp-image-123',
services: [ 'pinterest', 'facebook', 'twitter' ]
});
Example 3: Target Multiple Images or Classes
To target multiple images, use a comma-separated list of selectors.
a2a_config.overlays.push({
target: 'img.wp-image-123, img.wp-image-456, img.gallery-item',
services: [ 'pinterest', 'facebook', 'twitter' ]
});
3. Change the Minimum Image Size (Advanced)
While the sample threads show users asking for a way to change the default 200x200 pixel minimum, this is not a setting that can be easily adjusted through standard configuration. The AddToAny team has indicated this is a core behavior. The most practical workaround is to use the JavaScript targeting method above to only apply buttons to images that meet your larger size criteria, perhaps by giving them a specific CSS class.
4. Exclude Site Sections (Future Update)
Based on user feedback, the AddToAny team has indicated that a future update may automatically exclude images within <header> and <footer> tags by default. Until then, you can manually add exclusion attributes to images in those areas or use a more specific CSS selector in your JavaScript (e.g., header img, footer img { data-a2a-overlay="false"; } via custom CSS).
Troubleshooting Tips
- Code Warnings: If you get "Unexpected Token" warnings when adding code to the "Additional JavaScript" box, ensure your code is valid. A simple test is to start with the most basic code:
a2a_config.overlays.push({});and see if the warnings disappear. - Clear Caches: After adding any JavaScript or CSS customizations, remember to clear your WordPress cache (if you use a caching plugin) and your browser cache to see the changes.
- Check for Conflicts: If your custom code isn't working, try temporarily disabling other plugins to rule out a JavaScript conflict.
By using these targeting techniques, you can finely control the appearance of AddToAny share buttons, ensuring they only appear on the images you want your visitors to share.
Related Support Threads Support
-
Set Default Images Sizes For Image Share Buttonshttps://wordpress.org/support/topic/set-default-images-sizes-for-image-share-buttons/
-
How to share different images, which are in the same posthttps://wordpress.org/support/topic/how-to-share-different-images-which-are-in-the-same-post/
-
Adding share buttons to Lightboxhttps://wordpress.org/support/topic/adding-share-buttons-to-lightbox/
-
Disable showing buttons on imageshttps://wordpress.org/support/topic/disable-showing-buttons-on-images/
-
Image sharinghttps://wordpress.org/support/topic/image-sharing-3/
-
Share Single Imageshttps://wordpress.org/support/topic/share-single-images/
-
AddToAny: I don’t know how to apply share button images in wordpresshttps://wordpress.org/support/topic/addtoany-i-dont-know-how-to-apply-share-button-images-in-wordpress/
-
Excluding multiple images (specific ones) from being sharedhttps://wordpress.org/support/topic/excluding-multiple-images-specific-ones-from-being-shared/
-
Share Buttons for Nextgen Gallery-Imageshttps://wordpress.org/support/topic/share-buttons-for-nextgen-gallery-images/
-
Button on slideshowhttps://wordpress.org/support/topic/button-on-slideshow-2/
-
Sharing only specfic images- So close to solutionhttps://wordpress.org/support/topic/sharing-only-specfic-images-so-close-to-solution/
-
No IMAGE Share Buttonshttps://wordpress.org/support/topic/no-image-share-buttons/
-
Image Buttons defaultshttps://wordpress.org/support/topic/image-buttons-defaults/
-
Disable sharing buttons appearing on imageshttps://wordpress.org/support/topic/disable-sharing-buttons-appearing-on-images/
-
Image share buttons – share specific image with page linkhttps://wordpress.org/support/topic/image-share-buttons-share-specific-image-with-page-link/
-
Disable overlay on imagehttps://wordpress.org/support/topic/disable-overlay-on-image/
-
Single images sharing option not workinghttps://wordpress.org/support/topic/single-images-sharing-option-not-working/
-
Url of image sharinghttps://wordpress.org/support/topic/url-of-image-sharing/
-
Image share button settingshttps://wordpress.org/support/topic/image-share-button-settings/
-
Can this plugin create image share buttons?https://wordpress.org/support/topic/can-this-plugin-create-image-share-buttons/
-
Always show Image Share buttonshttps://wordpress.org/support/topic/always-show-image-share-buttons/
-
Print button single image printhttps://wordpress.org/support/topic/print-button-single-image-print/
-
Change default image sizehttps://wordpress.org/support/topic/change-default-image-size-4/