Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 5973429
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T20:47:56+00:00 2026-05-22T20:47:56+00:00

Hiya, I have run into this problem many times now using drupal or wordpress

  • 0

Hiya,
I have run into this problem many times now using drupal or wordpress where my tinymce config files are a bit too cleverly abstracted.

The problem is that tinymce auto-wraps my <img> tags in <p> tags. If there is a way around this in either WordPress or Drupal, that would be awesome.

My problem exists when I want to do something like this

<style>
    img {
        float: left;
    }
    p {
        float: right;
        margin-right: 20px;
        width: 400px;
    }
 </style>

and I want my code to look like this

<img src="some_png.png" />
<p> Imagine a lot of lipsum text.</p>

but tinymce does this

<p><img src="crap_im_wrapped_in_a_paragraph.png" /></p>
<p> Imagine a lot of lipsum text.</p>

I’m trying to float an image to the left of a paragraph with a set width, without having width restraints on the image itself.
in this case the image’s parent then gets a width and a float right. That is not what I want.

It is very possible that there is an easy clever fix for this but I still have not found one. I would prefer not hacking my config files if I don’t have to.

1 caveat…
The only reason this problem exists is because I want clients to be able to easily do their own editing so I won’t just have them wrap the image in a <div> instead of a <p>. That seems to me unintuitive for my clients who are the actual users of the wysiwyg

Previous Solution
I have been using a regex to remove the paragraph tags but it is always somehow problematic. I end up adding more images somewhere else then i have to keep tuning my regex to ignore them. 502 errors abound!

my question(s) is(are)
What can I to in my CSS to make the image wrapped in the paragraph do what I want it to do?
and if i can’t
What drupal or wordpress specific can I do to make that paragraph disappear?

— Edit —
the solution needs to be compatible with IE7+ and modern browsers. 😛

Thanks!
aaron

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-22T20:47:57+00:00Added an answer on May 22, 2026 at 8:47 pm

    If you don’t want it to wrap image tags, look in the Tinymce source for a function called “isBlock”. There is a regular expression white list test that determines whether or not an element is a block element. If you need image tags to be treated as block elements then add “IMG” to the list of node names it looks for. I just had to do this myself, am still looking for negative side effects right now but it does solve the immediate problem at hand.

    EDIT:
    That was more or less a temporary solution, if you just need to stop the root level block wrapping of image tags, there’s a function called “forceRoots” where you’ll actually want to perform your image tag check. I did it by modifying this line of code:

    if (nx.nodeType == 3 || (!t.dom.isBlock(nx) && nx.nodeType != 8)) {
    

    to look like this:

    if (nx.nodeType == 3 || (!t.dom.isBlock(nx) && nx.nodeType != 8) && nx.nodeName.toLowerCase() != "img") {
    

    This solves the problem quite well for me.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Hiya guys heres my question: im using mootools and im using this demo-> Drag.Move
I have this markup, <a href=http://www.example.com>Hiya<span class=delete>Delete</span></a> And my js, $('.delete').click(function() { window.location =
Hiya - been pointed at you guys by a friend of mine. I have
Hiya I am very new to C#, infact this is basically my first task
hiya, i have the following code but when i try and create a new
hiya i have a massive job trying to sort thousands of records all is
I have another Javascript regex conundrum... (apologies if this is a bit long-winded -
I donwloaded this release, and I'm trying to run an example from the docs.
Hiya! I'm having problems with z-index in IE7. I have a table where the
I have been trying to get this to work and can't. I have a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.