coresocial_get_post_image
Developer Knowledge Level
This content is intended for WordPress developers, and it may require coding knowledge of WordPress, PHP, and JavaScript. Code examples provided here may contain errors or needs some additional coding. Make sure to test the code before using it on a live website!
PHP
Definition
apply_filters( "coresocial_get_post_image", $image, $attachment_id, $post, $method );
Arguments
Name
Type
Description
$image
string
Featured-image URL, or an empty string when unavailable.
$attachment_id
int|false
Featured-image attachment ID, or false when the post cannot be resolved.
$post
WP_Post|null
Resolved post object.
$method
Dev4Press\Plugin\coreSocial\Base\Method
Current method instance.
Returns
string — featured-image URL.
Filters the featured-image URL used by sharing methods. Starting in coreSocial 4.0, move image-specific callbacks from coresocial_get_post_url to this hook. The erroneous old image invocation has been removed so permalink callbacks consistently receive a post object as their second argument.
Example
add_filter( 'coresocial_get_post_image', function ( $image, $attachment_id, $post, $method ) {
return $image !== '' ? $image : 'https://example.com/default-social.jpg';
}, 10, 4 );