WYSIWYG Auto P Tags

Support General WYSIWYG Auto P Tags

Viewing 9 posts - 1 through 9 (of 9 total)
  • Author
    Posts
  • #39182
    JohnJohn
    Participant

    Hello,

    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!

    #39190
    PeterPeter
    Moderator

    Hello 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.

    #39199
    JohnJohn
    Participant

    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?

    #39211
    PeterPeter
    Moderator

    Hello 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.

    #39212
    JohnJohn
    Participant

    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.

    Thanks!

    John

    #39606
    Anh TranAnh Tran
    Keymaster

    Hi John,

    If you set the raw to 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 raw to true, then the data saved is always applied with wpautop, thus, you'll see the <p> tag on the front end.

    #39611
    JohnJohn
    Participant

    Thank you so much Anh, I think I got it and understand now! Have a great rest of your day.

    #40152
    LucaLuca
    Participant

    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.

    Thanks again.

    #44532
    HazmiHazmi
    Participant

    Hi,

    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 with clone = true

    WP 6.4.3
    Metabox 5.9.0
    Metabox Group 1.3.18

Viewing 9 posts - 1 through 9 (of 9 total)
  • You must be logged in to reply to this topic.