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! 🎄
Hello.
We use for ages now a small code provided by the support guys, that each attachment that was a photo, was show inline (embeded) to the body. Worked perfectly well.
Now it seems something changed, and if I EDIT such a post, the image becomes attachment after saving.
Any ideas how to fix this?
Thanks
The code is:
add_filter('wpforo_content_after', 'wpforo_default_attachment_image_embed', 11);
function wpforo_default_attachment_image_embed($content)
{
if (preg_match_all('|<a class=\"wpforo\-default\-attachment\" href\=\"([^\"\']+)\"[^><]*>.+?<\/a>|is', $content, $data, PREG_SET_ORDER)) {
foreach ($data as $array) {
if (isset($array[1])) {
$file = $array[1];
$e = strtolower(substr(strrchr($file, '.'), 1));
if ($e == 'jpg' || $e == 'jpeg' || $e == 'png' || $e == 'gif') {
$filename = explode('/', $file);
$filename = end($filename);
$html = '<a href="' . esc_url($file) . '" target="_blank"><img class="wpforo-default-image-attachment" src="' . esc_url($file) . '" alt="' . esc_attr($filename) . '" title="' . esc_attr($filename) . '" /></a>';
$content = str_replace($array[0], $html, $content);
}
}
}
}
return $content;
}
14-Oct-2021 16:53:33 UTC] PHP Warning: preg_replace_callback(): Compilation failed: unrecognized character after (? or (?- at offset 23 in /home/wp-content/plugins/custom-functions/custom-functions.php on line 52
Line 52 is
$content
Works fine now, many thanks.