I am inserting an image into the WYSIWYG custom field type.
The image is wrapped with a p tag.
Is it possible to remove the p tag or add other tags such a figure?
I looked into the raw format option, but it did not remove the p tag.
I do not experience that issue on my end, if you insert the image from the button "Add media" in the WYSIWYG field, you can switch to the tab Text and see the HTML tag
<img> added without
Hi Peter, thanks for the response.
Inside the WYSIWYG editor, there is no p tag. I see you can change the tags using the raw HTML editor.
But on the front end, the output automatically wraps the image in a p tag.
I am trying to clean up the output on the front end and remove the automatic p tag wrap on the image.
Any thoughts on why this is happening?
Thanks, I see that issue. I've escalated it to the development team to check. I will let you know if I get any information from the team.
Hey Peter, the p tag is coming from the WordPress
wpautop function I believe.
If I manually wrap the image in a span tag or anything else using the HTML code view, it works correctly on the frontend.
The issue is that a client not versed in html won't know to do that.
It would be nice to define how images are handled when inserted in the Wysiwyg field.
So, instead of the wpautop function doing it's thing on images in the wysiwyg field, maybe some further customization or settings would help clean up the frontend output when using images in this type of Metabox field.
If you set the
false (which is default), then the data saved in the custom field is not applied with
wpautop. So, you can just get it with
$value = rwmb_meta( 'field_id' ); echo $value; // no wpautop
If you set the
true, then the data saved is always applied with
wpautop, thus, you'll see the
<p> tag on the front end.
Thank you so much Anh, I think I got it and understand now! Have a great rest of your day.
Thanks for the tip.
I would suggest to add a small tooltip to the "Save data in the raw format" checkbox available in the WYSIWYG field settings.