frm_display_value remove base64 "data:" attribute on entry view
Closed this issue · 1 comments
We generate a barcode and store this as base64 string.
We use the hook frm_display_value to output the result as html image.
When previewing the entry list, this is also displayed correctly. However, when viewing the individual entry, the data:
is removed, so that the image cannot be displayed.
inside hook:
$value = '<img src="' . $value . '" />';
Output:
<img id="" src="image/png;base64,iVBORw0...">
Are there any solutions?
Hi @waigel sorry for never getting back to you on this. We just normally use our support channels for issues rather than here in GitHub.
I had a team member look into this issue and it's because of how the HTML is sanitized with the WordPress kses function.
Your base64 data should be able to save properly if you have this snippet active when it saves the data.
add_filter( 'kses_allowed_protocols', function( $protocols ) {
$protocols[] = 'data';
return $protocols;
} );
Here's a link with more information where others had the same issue with WordPress https://wordpress.stackexchange.com/questions/353550/how-to-allow-dataimage-attribute-in-src-tag-during-post-insert/353602#353602