Notifications
Clear all

wpForo 1.x.x [Closed] My forum share button is selecting a particular image thumbnail for all the post,topic discussions

9 Posts
4 Users
0 Likes
2,697 Views
Posts: 4
Topic starter
(@hertzelectroz)
Active Member
Joined: 5 years ago

please how can i fix this error in my site, please can anyone help

8 Replies
Robert
Posts: 10499
Admin
(@robert)
Support Team
Joined: 8 years ago

Please leave your website URL to allow us check it. And provide an example.

1 Reply
(@hertzelectroz)
Joined: 5 years ago

Active Member
Posts: 4
Robert
Posts: 10499
Admin
(@robert)
Support Team
Joined: 8 years ago

You don't have any image in topics and posts so it selects first found image from your website. This is normal. wpForo detects images in topic first post content when you try to share a topic and it sets found first image as share image. Here is a good topic to see that in action: https://wpforo.com/community/general-discussions/sharing-wpforo-links-on-linkedin/

For non-topic (forum home, forums and other) pages and for topics without an image wpForo allows to set default share image.  That's the default share image (og:image share tag) . You should put this code in WordPress theme functions.php file to set it. Just change the red marked image URL to your website/forum logo URL or to something else, it'll be the default share image:

function my_default_og_image( $image_url, $type ){
if( $type == 'og:image' && !$image_url){
return 'https://example.com/images/mylogo.jpg';
}
else{
return $image_url;
}
}

add_filter('wpforo_find_image_url', 'my_default_og_image', 10, 2);

How to Easily Add Custom Code in WordPress (without Breaking Your Site)

 

 

Posts: 23
(@illinipulse)
Eminent Member
Joined: 5 years ago

Searching through the help forum and ran across this topic.

Is there a way to share a specific image from a post to Twitter/Facebook, or only the default option above?

Posts: 23
(@illinipulse)
Eminent Member
Joined: 5 years ago
Posted by: @robert

function my_default_og_image( $image_url, $type ){
if( $type == 'og:image' && !$image_url){
return 'https://example.com/images/mylogo.jpg';
}
else{
return $image_url;
}
}

add_filter('wpforo_find_image_url', 'my_default_og_image', 10, 2);

I entered this into my child theme (after changing the image example to my own) and it doesn't work.  Any ideas?

1 Reply
(@illinipulse)
Joined: 5 years ago

Eminent Member
Posts: 23

I put into my main theme functions.php and it still didn't work.  I get this:

Page 1 / 2