New Landing How can we help? Themeforest Theme Support Dante Pinterest button not working correctly

Viewing 8 posts - 1 through 8 (of 8 total)
  • Posted in: Dante
  • #208650
    camind
    Member
    Post count: 228

    hi guys,

    When pressing the pinterest button invalid image data uri error comes up. Ofcourse this happens when you are logged in and the system looks for images to pick. So this error stops the ability to put images on pinterest. See attachment

    Thanks

    Attachments:
    You must be logged in to view attached files.
    #209202
    David Martin – Support
    Moderator
    Post count: 20834

    Hi,

    This relies on the posts featured image being set, have you done this for your post? Without a featured image, no image URL is passed to Pinterest.

    Thanks,
    David.

    #209416
    camind
    Member
    Post count: 228

    Hi,

    Can this somehow be changed to use all images on page? my old site was able to give the user the option on which picture they wanted to use and showed all pictures on that page. This makes sense because the user might want to pin an image that is not the featured image. Also on top of that I don’t use the feature image for anything at all right now so having to add featured images to all my posts would be a lot of work just to have pinterest to work.

    Thanks

    #209903
    David Martin – Support
    Moderator
    Post count: 20834

    Hi,

    If you are looking to add a pinterest link to all image within a post, this plugin would be for you: https://wordpress.org/plugins/pinterest-pin-it-button-for-images/.

    The default pinterest link can only send one image to Pinterest, hence the featured image. We could look into making it default to the first image uploaded to the post, but that would give you less control. So the above plugin would sounds better for your case.

    Thanks,
    David.

    #209908
    camind
    Member
    Post count: 228

    David,

    Can we make the existing link use the first image of the post? That way I can avoid uploading all featured images and will save me hrs of time. and also avoid using the extra plugin.

    thanks

    #210380
    David Martin – Support
    Moderator
    Post count: 20834

    Hi,

    1) Please activate your child theme.

    2) Copy and paste this into your child theme functions.php file

    if (!function_exists('swift_pinterest_get_first_image_in_post')) {
    	function swift_pinterest_get_first_image_in_post() {
    	global $post, $posts;
    	  $first_img = '';
    	  ob_start();
    	  ob_end_clean();
    	  $output = preg_match_all('/<img.+src=[\'"]([^\'"]+)[\'"].*>/i', $post->post_content, $matches);
    	  $first_img = $matches[1][0];
    
    	  if(empty($first_img)) {
    	    $first_img = ""; // You can also set a default image path
    	  }
    	  return $first_img;
    	}
    }

    3) Within you child theme create a new file, called single.php.

    4) Copy and paste the code into single.php. Full code here, please copy this exactly. http://pastie.org/private/karqmo0rttxh6zrfd3f8jg#233.

    That will do it.

    Thanks,
    David.

    #210545
    camind
    Member
    Post count: 228

    Thanks David, You’re the man 🙂

    #210827
    David Martin – Support
    Moderator
    Post count: 20834

    No problem, happy to help!

    -David.

Viewing 8 posts - 1 through 8 (of 8 total)

You must be logged in and have valid license to reply to this topic.

License required for one of the following items
Login and Registration Log in · Register