Apr 30, 2020 3:34 pm
Hi Guys!
Is there a way to show converted URL images without the source link?
Thanks in advance.
1 Reply
May 01, 2020 1:22 pm
Hi @igor,
Please put the following code in the functions.php file of the active theme:
add_filter('comment_text', function ($content, $comment, $args = []) {
$wpdiscuz = wpDiscuz();
if ($wpdiscuz->isWpdiscuzLoaded) {
$content = preg_replace_callback('@src\s*=\s*"(.+?)"@is', function ($matches) {
$file = get_headers($matches[1], 1);
return 'src="data: ' . $file['Content-Type'] . ';base64,' . base64_encode(file_get_contents($matches[1])) . '"';
}, $content);
}
return $content;
}, 999, 3);
Please don't forget to delete all caches and press CTRL+F5(twice) on the frontend before checking.
Also please note the code provided above will change all images as you describe in the post above.