Viewing 8 replies - 1 through 8 (of 8 total)
  • Plugin Author Sybre Waaijer

    (@cybr)

    Hi Chris,

    Could you check out this documentation? https://www.linkedin.com/help/linkedin/answer/46687/making-your-website-shareable-on-linkedin?lang=en

    They say there’s a minimum image dimension required–you’re just 6 pixels off in width. Hopefully adding those will resolve it. I’m not sure why they recommend using name=image in the inspector.

    Currently, and it’s a bit hard to spot (you have to click the value on the left-hand at “Metadata that we gathered about this page:”), they say they take the image from the oEmbed.

    • This reply was modified 4 years, 7 months ago by Sybre Waaijer. Reason: clarity
    Thread Starter cjyabraham

    (@cjyabraham)

    Thanks for the quick response. I checked the image size, however, even one of our images that is much larger doesn’t work. It is set on this page. They are set using the tags described on the LinkedIn doc so not sure why it’s not working. Is this working for you properly on your sites?

    Plugin Author Sybre Waaijer

    (@cybr)

    Hello!

    I just tested it, and annoyingly, LinkedIn prefers using oEmbed over Open Graph over Articles schema.

    You have two options:

    1. Disable oEmbed (TSF has an option under Social Meta Settings > General > “Output oEmbed scripts?”). This might hamper some integrations and accessibility;
    2. Replace the oEmbed image with TSF’s social image (if present).

    I’m not sure if I should make the second option a toggle in TSF. Nevertheless, this snippet should do the trick:

    add_filter( 'oembed_response_data', [ $this, 'my_alter_oembed_response_data' ], 10, 4 );
    /**
     * @param array   $data   The response data.
     * @param WP_Post $post   The post object.
     * @param int     $width  The requested width.
     * @param int     $height The calculated height.
     * @return array Possibly altered $data.
     */
    function my_alter_oembed_response_data( $data, $post, $width, $height ) {
    	
    	if ( ! empty( $data['thumbnail_url'] ) ) {
    		$tsf = function_exists( 'the_seo_framework' ) ? the_seo_framework() : null;
    
    		if ( ! $tsf ) return $data;
    
    		$image_details = current( $tsf->get_image_details(
    			[
    				'id'       => $post->ID,
    				'taxonomy' => '', // fill index to improve performance.
    			],
    			true,     // Get single image
    			'embed',  // context -- Don't use 'social', that'll enable fallback images.
    			true,     // sanitize, get expected output
    		) );
    
    		if ( $image_details['url'] && $image_details['width'] && $image_details['height'] ) {
    			// Override WordPress provided data.
    			$data['thumbnail_url']    = $image_details['url'];
    			$data['thumbnail_width']  = $image_details['width'];
    			$data['thumbnail_height'] = $image_details['height'];
    		}
    	}
    
    	return $data;
    }

    I wasn’t too sure bout the conditionals–i.e., should we always include the thumbnail_url, or only when there’s one set by WordPress?

    Nevertheless, I hope this solves the issue you’re facing ?? Cheers!

    • This reply was modified 4 years, 7 months ago by Sybre Waaijer. Reason: typos
    Thread Starter cjyabraham

    (@cjyabraham)

    hi Sybre,
    We already disable wp-embed in the code so I don’t think this is causing the problem. I also tried de-selecting the option on our dev site but I’m still seeing the same social image used on LinkedIn. Any other ideas?

    Thanks,
    Chris

    Plugin Author Sybre Waaijer

    (@cybr)

    Hi Chris,

    The code you implemented disables showing embeds in your content on your site. But not from your site.

    Others look for the application/json+oembed and text/xml+oembed scripts linked on your site. To remove those, you’ll need to use this:

    remove_action( 'wp_head', 'wp_oembed_add_discovery_links' );
    

    This hook is added before plugins load; so, you can put it anywhere. TSF implements that when you untick the “Output oEmbed scripts?” option under Social Meta Settings.

    LinkedIn seems to take the image from the og:image tag of your dev site now (perhaps when you looked there was a caching issue?). So, I believe we’re still on the right track ??

    Thread Starter cjyabraham

    (@cjyabraham)

    Interesting. Ok. Yes, there does seem like there was a cache at play. I’ve now got it working on the live site. This is good enough for now. Thanks for your help and for a great plugin.

    Plugin Author Sybre Waaijer

    (@cybr)

    Hi Chris,

    I hope you like Friday-releases… because TSF v4.1.1 is now available!
    In it, you’ll find new oEmbed options, one of which mimics the custom snippet I sent to you earlier in this topic.

    The option you’re looking for is disabled by default for upgrading sites but enabled for new sites.

    Cheers ??

    Thread Starter cjyabraham

    (@cjyabraham)

    Excellent! Thanks for the update.

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘LinkedIn social image?’ is closed to new replies.