Every time I edit a WordPress post or page that has a google map embedded in it – useing the “visual” edit mode – wordpress deletes part of the data.
for example: this
<iframe width="425" height="350" frameborder="0" scrolling="no" marginheight="0" marginwidth="0" src="http://maps.google.com/maps/ms?ie=UTF8&hl=en&msa=0&msid=212526618623367333770.00049b7dc074f6426719d&t=h&ll=34.926059,-81.964874&spn=0.300106,0.458336&output=embed"></iframe><br /><small>View <a href="http://maps.google.com/maps/ms?ie=UTF8&hl=en&msa=0&msid=212526618623367333770.00049b7dc074f6426719d&t=h&ll=34.926059,-81.964874&spn=0.300106,0.458336&source=embed" style="color:#0000FF;text-align:left">1825 Spartanburgh Map</a> in a larger map</small>
turns into
<small>View <a style="color: #0000ff; text-align: left;" href="http://maps.google.com/maps/ms?ie=UTF8&hl=en&msa=0&msid=212526618623367333770.00049b7dc074f6426719d&ll=34.926059,-81.943846&spn=0.300106,0.416279&source=embed">1825</a> in a larger map</small>
Which does not render the map at all.
This does not happen when I edit in “html” mode.
How can I prevent WordPress from altering this embed code?
The issue is WordPress’ core configuration of TinyMCE, which strips IFRAME tags.
You can modify this configuration, to allow IFRAME tags, by hooking into
tiny_mce_before_init
. For example, the following code will prevent TinyMCE from stripping IFRAME, PRE, and DIV tags:See here for the full list of configurable options.
I don’t know for certain, but I think it may be related to the allowed tags for posts. See my question from a few days ago. Basically wordpress will filter out tags that are not allowed. So for example you could prevent script tags. You also have to specify what parameters are allowed. So for instance you could allow an img tag with the src attribute, but not the alt attribute.
What are allowedposttags and allowedtags?