php – base64_encode conflict with convert_smilies in wordpress

Question

I am trying to show image in my wordpress website which get from third-party. They give me raw data of image. For showimg image, I need to convert raw data(which get from third-party) to base64_encode. It was working perfectly but recently got an error with a specific image. For all other image is working perfectly.

I have debug and found the issue was create for base64_encode($file).

My Code :

$file = "image raw data which get form third-party";
$type = "image type"; // png, jpg, jpeg
$en_data = base64_encode($file);
<img src="data:image/<?=$type;?>;base64, <?= $en_data; ?> ">

Error :

Fatal error: Uncaught TypeError: count(): Argument #1 ($value) must be
of type Countable|array, bool given in
E:\xampp\htdocs\dev\wp-includes\formatting.php:3415 Stack trace: #0
E:\xampp\htdocs\dev\wp-includes\class-wp-hook.php(307):
convert_smilies(‘\r\n<style type=”…’) #1
E:\xampp\htdocs\dev\wp-includes\plugin.php(191):
WP_Hook->apply_filters(‘\r\n<style type=”…’, Array) #2
E:\xampp\htdocs\dev\wp-includes\post-template.php(253):
apply_filters(‘the_content’, ‘<!– wp:shortco…’) #3
E:\xampp\htdocs\dev\wp-content\plugins\my-plugin\pagetemplate\page_fullwidth-template.php(11):
the_content() #4
E:\xampp\htdocs\dev\wp-includes\template-loader.php(106):
include(‘E:\xampp\htdocs…’) #5
E:\xampp\htdocs\dev\wp-blog-header.php(19):
require_once(‘E:\xampp\htdocs…’) #6
E:\xampp\htdocs\dev\index.php(17): require(‘E:\xampp\htdocs…’) #7
{main} thrown in E:\xampp\htdocs\dev\wp-includes\formatting.php on
line 3415

There has been a critical error on this website.

Thanks in advance

0
Mahidul Islam 4 weeks 2022-08-30T00:48:33-05:00 0 Answers 0 views 0

Leave an answer

Browse
Browse