WYSIWYG Auto P Tags
- This topic has 8 replies, 5 voices, and was last updated 1 year, 2 months ago by
Hazmi.
-
AuthorPosts
-
November 17, 2022 at 9:56 AM #39182
John
ParticipantHello,
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.
https://docs.metabox.io/fields/wysiwyg/Thank you!
November 17, 2022 at 10:16 PM #39190Peter
ModeratorHello John,
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<p>
tag.November 18, 2022 at 1:43 AM #39199John
ParticipantHi 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?
November 19, 2022 at 9:34 AM #39211Peter
ModeratorHello John,
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.
November 19, 2022 at 10:19 AM #39212John
ParticipantHey 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.
Thanks!
John
December 8, 2022 at 5:09 PM #39606Anh Tran
KeymasterHi John,
If you set the
raw
tofalse
(which is default), then the data saved in the custom field is not applied withwpautop
. So, you can just get it with$value = rwmb_meta( 'field_id' ); echo $value; // no wpautop
If you set the
raw
totrue
, then the data saved is always applied withwpautop
, thus, you'll see the<p>
tag on the front end.December 8, 2022 at 8:31 PM #39611John
ParticipantThank you so much Anh, I think I got it and understand now! Have a great rest of your day.
January 8, 2023 at 1:00 AM #40152Luca
ParticipantThanks 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.
Thanks again.
February 10, 2024 at 6:57 PM #44532Hazmi
ParticipantHi,
no matter what i set..
raw = true
shows data from wysiwyg editor without<p>
tag. I have to use wpautop function to get tags on the frontend. I'm using Metabox Group externsion withclone = true
WP 6.4.3
Metabox 5.9.0
Metabox Group 1.3.18 -
AuthorPosts
- You must be logged in to reply to this topic.