Viewing 5 replies - 1 through 5 (of 5 total)
  • Hey Chrissy,

    thanks for reaching out – I’ll gladly help! But first, would you mind telling me which “nopin” plugin are you using? Also, a link to your blog would be much appreciated.

    Take care and have a nice day,
    Petra

    Thread Starter Chrissy

    (@paperkawaii)

    Hi Petra,

    My blog is https://www.paperkawaii.com

    The ‘nopin’ I want to add to stop the pinmarklet or the any pin plugin from being able to pin the tiny thumbnails used by the related post plugin.

    To stop images being pinnable, you have to add

    nopin="nopin"

    Hope that helps ??

    Hey,

    thanks for getting back to me. The following changes should work:

    1.) In the plugin’s thumbnailer.php file (lines 205-215) find the function wp_rp_get_img_tag and change the line 213:
    return '<img src="'. esc_attr($src) . '" alt="' . esc_attr($alt) . '" '.$size_attr.' nopin="nopin"/>';
    2.)replace the lines 236 – 283 (function function wp_rp_get_image_with_exact_size) with this code (we added ‘nopin’=> ‘nopin’ in two places – you can just add that to the lines 263, 277 or copy/paste/replace the code):

    function wp_rp_get_image_with_exact_size($image_data, $size) {
        # Partially copied from wp-include/media.php image_get_intermediate_size and image_downsize
        if (!$image_data) { return false; }
        $img_url = wp_get_attachment_url($image_data['id']);
        $img_url_basename = wp_basename($img_url);
        $platform_options = wp_rp_get_platform_options();
        // Calculate exact dimensions for proportional images
        if (!$size[0]) { $size[0] = (int) ($image_data['data']['width'] / $image_data['data']['height'] * $size[1]); }
        if (!$size[1]) { $size[1] = (int) ($image_data['data']['height'] / $image_data['data']['width'] * $size[0]); }
        $w = $image_data['data']['width'];
        $h = $image_data['data']['height'];
        $thumb_width = $platform_options['custom_size_thumbnail_enabled'] ? $platform_options['custom_thumbnail_width'] : WP_RP_THUMBNAILS_WIDTH;
        $thumb_height = $platform_options['custom_size_thumbnail_enabled'] ? $platform_options['custom_thumbnail_height'] : WP_RP_THUMBNAILS_HEIGHT;
        $default_sizes = $w == $thumb_width && $h == $thumb_height;
        $matches_sizes = $w == $size[0] && $h == $size[1];
        if (!$image_data['data']['sizes'] && $default_sizes || $matches_sizes) {
            $file = explode("/", $image_data['data']['file']);
            $file = $file[count($file) - 1];
            $img_url = str_replace($img_url_basename, wp_basename($file), $img_url);
            return array(
                'url' => $img_url,
                'file' => $file,
                'width' => $w,
                'height' => $h,
                'nopin'=> 'nopin'
            );
        }
    
        foreach ($image_data['data']['sizes'] as $_size => $data) {
            // width and height can be both string and integers. WordPress..
            if (($size[0] == $data['width']) && ($size[1] == $data['height'])) {
                $file = $data['file'];
                $img_url = str_replace($img_url_basename, wp_basename($file), $img_url);
                return array(
                    'url' => $img_url,
                    'file' => $data['file'],
                    'width' => $data['width'],
                    'height' => $data['height'],
                    'nopin'=> 'nopin'
                );
            }
        }
        return false;
    }

    Don’t forget to save the changes and please note that if/when you will update the plugin these modifications will disappear (so, please make a backup)!

    Please let me know how it goes, take care and have a nice day,
    Petra

    Thread Starter Chrissy

    (@paperkawaii)

    Wow, thanks so much, the changes worked, thats great!

    Thanks so much for looking into that for me!

    X Chrissy ?

    Glad to hear it worked! ??

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘WordPress Related Posts add nopin to images’ is closed to new replies.