Envira Gallery Documentation

Documentation, Reference Materials and Tutorials for Envira Gallery

How To Disable Pinterest Pin It Button (Browser Extension)

Would you like to turn off the Pinterest Pin It Button for your gallery images? You can easily do this by installing a custom plugin. We’ll walk you through the steps on how to disable the Pinterest Pin It Button for your gallery images.

This tutorial is a bit more technical than our other docs. In order to use disable the Pinterest Pin It Button, please review the steps below.

To turn off the Pin It Button, you’ll first need to start by simply adding the following code to a new file at wp-content/plugins/envira-gallery-disable-pinterest-button.php.

<?php
/**
* Plugin Name: Envira - Disable Pinterest Button on Image Hover
* Plugin URI: https://enviragallery.com
* Version: 1.0
* Author: Envira Gallery Team
* Author URI: https://enviragallery.com
* Description: Adds nopin="nopin" to Envira Gallery Images, disabling the Pinterest Button when hovering over an image.
*/
/**
 * Adds nopin="nopin" to Envira Gallery Images, disabling the Pinterest Button when hovering over an image.
 *
 * @param string    $atts   &amp;lt;img&amp;gt; tag attributes
 * @param int       $id     Image ID
 * @param array     $item   Image Data
 * @param array     $data   Gallery Config
 * @param int       $i      Index
 * @return string           Image Attributes
 */
function envira_disable_pinterest_button( $atts, $id, $item, $data, $i ) {
    return $atts . 'nopin="nopin"';
}
add_filter( 'envira_gallery_output_image_attr', 'envira_disable_pinterest_button', 10, 5 );
add_filter( 'envira_albums_output_image_attr', 'envira_disable_pinterest_button', 10, 5 );

If you’re unsure how to create a plugin file, follow these steps below:

  1. Open a text file and make sure that it is a plain text document. You can use a plain text editor like Notepad or a code editor of your choice.
  2. Next, copy and paste the code shown below that matches the page builder you’re using into the file and save the file as envira-gallery-disable-pinterest-button.php
  3. Once you’ve saved the file you can easily upload this directly to your /plugins directory on your server using FTP or you can right-click on the text document and zip (or compress).
  4. Finally, log in to your WordPress dashboard and go to Plugins » Add New » Upload Plugin and upload the .zip file you just created in the previous step.

Your next step is to activate the plugin you just uploaded. Simply navigate to the Plugins from within your WordPress dashboard and activate the Envira – Disable Pinterest Button on Image Hover plugin.

Disable the Pinterest Pin It Button on Envira Gallery images

And that’s it, you’re all done! Would you like to try some more cool things with Envira? Check out our tutorial on How to Style Pagination Links.


A: Yes, the above code will disable the Pin It button for both galleries and albums.