Support Forum
Support › MB Frontend Submission › WYSIWYG Editor Alters HTML Code?
Hi,
I use WYSIWYG Editor in a form with Add Media button on. Upon submitting the form with an image, the image link is broken; check Screen 1.
Upon checking the content in the editor's code view, I noticed that:
1. there are additional quotes added; check Screen 2 (marked in red);
2. the "x" in the file name was replaced by multiplication symbol, while the actual file name has a regular "x" letter; check Screen 2 (marked in blue).
I use the following code for the field:
[
'name' => esc_html__( 'Content', 'domain' ),
'id' => $prefix . 'post_content',
'type' => 'wysiwyg',
'std' => '-',
'raw' => true,
'options' => [
'wpautop' => false,
'textarea_rows' => 8,
'tinymce' => [
'paste_remove_styles' => true,
'paste_remove_spans' => true,
'paste_strip_class_attributes' => true,
'block_formats' => 'Paragraph=p; Heading 2=h2; Heading 3=h3',
'toolbar1' => 'formatselect,bold,italic,superscript,subscript,bullist,numlist,link,unlink,charmap',
],
'quicktags' => [
'buttons' => ',',
],
],
],
I am wondering if this has something to do with the field set up or something else.
Thanks.
Adding up to the above thread:
2. the "x" in the file name was replaced by multiplication symbol, while the actual file name has a regular "x" letter; check Screen 2 (marked in blue).
Inspecting the image with a browser's dev tools shows that the WYSIWYG Editor tries to display an image with the following name:
8c8d84253f9d31f33210869c6184ecc3-150%C3%97150.jpg
So, multiplication symbol is replaced with a code, which obviously points to a nonexistent file.
Hello,
I run your code on my demo site and add some images to the WYSIWYG field and save post but do not see that issue. Please try to disable all plugins except Meta Box, MB extensions, switch to a standard theme of WordPress and check this issue again.
I did that but nothing has changed. Every time I submit a form, additional quotation marks are added to the html code.
I made another test: I put this into the frontend visual editor:
"there"
(note typewriter quotation marks)
Upon saving the form, typewriter quotation marks were replaced with typographic ones:
”there”
However, when I edit the post in the WP backend, I see the classic editor block, with "there" (typewriter quotation marks).
So something interferes with the content in the frontend? Might that be any missing/present php module? I tested the issue with php 7.4.33 and 8.2.4.
Okay I found the reason why this happens: WP's wptexturize() function.
Disabling it with add_filter( 'run_wptexturize', '__return_false' );
fixes the issue.
Probably a better solution would be to use no_texturize_tags filter to have better control over which tags should not go through wptexturize().
I don't remember this happening before, I've only noticed this recently.
One more remark: I embed MB shortcodes in the Custom HTML block, not the Shortcode block, because I noticed that the latter one often broke my layout. I guess those two blocks handle wptexturize() function not the same way.
Switching to Shortcode block for embedding shortcodes instead of using Custom HTML block didn't fix the issue. Disabling wptexturize() function is still needed in my case.
Hello,
Can you please share your site (could be staging site) credentials via the contact form and details of the issue? I will take a look.
https://metabox.io/contact/
The website is unfortunately being developed offline. But the issue is fixed if I disable wptexturize() function. This is okay for me, I don't need it.