WordPress.org

Ready to get started?Download WordPress

Forums

Remove P tags from images (9 posts)

  1. gavinhallweb
    Member
    Posted 5 years ago #

    I cannot solve this one alone.

    Using web editor or MarsEdit, regardless of how i input the content into a new blog post, the following happens:

    I paste:
    <img src="WHATEVER" /><p>SOME CONTENT</p>

    And its translated into:
    <p><img src="WHATEVER" /></p><p>SOME CONTENT</p>

    So it assumes the image needs to be wrapped into a paragraph tag. I want to explicitly declare the difference in CSS between an img and a paragraph. Ive tried the advanced editor but doesnt help.

  2. MichaelH
    Member
    Posted 5 years ago #

    @gavinhallweb - deleted your duplicate threads.

  3. gavinhallweb
    Member
    Posted 5 years ago #

    Ok - surprised that no-one knows it tho as other designers must run straight into this one every time.

  4. gavinhallweb
    Member
    Posted 5 years ago #

    I half fixed by wrapping the whole entry in a div - not great but works.

  5. nintensity
    Member
    Posted 5 years ago #

    Hi there! I would like to know how to do this as well.
    Can anyone help the OP as well as me?

    I'm actually trying to give the P tag that is wrapped around the img tag a class attribute. Is this possible?

    thanks!

    -n

  6. spence88mph
    Member
    Posted 5 years ago #

    I've searched high and low for a solution for this.

    If someone can do it I'll pay them, very frustrating!!

    I know there is a plug-in that strips the <p> tags from everything, just want it to strip them from the images! I also know the div trick but it's not user friendly for a client.

    thanks

    Spence

  7. straydog
    Member
    Posted 5 years ago #

    http://wordpress.org/extend/plugins/disable-wpautop/

    This removes it from paragraphs as well though. I suggest you make a css element in which p img { margin: 0; } ?

  8. cfheinen
    Member
    Posted 4 years ago #

    One solution is through the use of JQuery's :has selector. It will allow you to look for paragraphs that contain <img>. This should do the trick:

    $("p:has(img)").css('margin' , '0');

    Check out this link for more info.

    http://docs.jquery.com/Selectors/has#selector

  9. cfheinen
    Member
    Posted 4 years ago #

    I elaborate further on how to use jQuery to solve this problem on my blog.

    http://www.heinencreative.com/archives/tutorials/ascendant-css-styling/

Topic Closed

This topic has been closed to new replies.

About this Topic