Limited Support
Our support team is currently on holiday from December 25, 2025 to January 7, 2026, and replies may be delayed during this period.
We appreciate your patience and understanding while our team is away. Thank you for being part of the wpForo community!
Merry Christmas and Happy Holidays! 🎄
May 29, 2025 11:12 am
I want to show images in my community topics/posts.
i do this with this code.
add_filter('wpforo_content_after', function( $content ){
return preg_replace_callback(
'#<a[^><]*\sclass=[\'\"](?:[^\'\"]*\s)?wpforo-default-attachment(?:\s[^\'\"]*)?[\'\"][^><]*\shref=[\'\"]([^\"\']+)[\'\"][^><]*>.*?</a>#isu',
function( $match ){
$html = $match[0];
$file = $match[1];
$pathinfo = pathinfo( $file );
if( wpforo_is_image($pathinfo['extension']) ) {
$html = sprintf(
'<a href="%1$s" target="_blank"><img class="wpforo-default-image-attachment" src="%1$s" alt="%2$s" title="%2$s"></a>',
esc_url($file),
esc_attr($pathinfo['basename'])
);
}
return $html;
},
$content
);
}, 11);
But i have to add this code after every update. Is there any other way to fix this issue.
1 Reply
May 30, 2025 10:01 am
Hi,
You can use the method described here: https://www.wpbeginner.com/plugins/how-to-easily-add-custom-code-in-wordpress-without-breaking-your-site/