Limited Support
Our team is currently on holiday, so support will be limited during this period. Response times may be slower than usual, and some inquiries may be delayed.
We appreciate your patience and understanding, and we’ll resume our usual support by the end of August.
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
Copy and paste the Code again, please. We have updated in my above reply.
Works fine now, many thanks.