I had a problem with TinyMCE and the advanced image button (assume this it the same with the basic one, but I've not checked it). There's no extended_valid_elements array item that includes the img tag.
I've created a workaround for the issue, which I've verified, but it's a nasty hack:
sites/all/modules/wysiwyg/editors/tinymce.inc
Find the code that starts:
// Clean-up.
$init['extended_valid_elements'] = array_unique($init['extended_valid_elements']);
From what I can work out, this is used to make sure that any 'extended_valid_elements' that are added by plugins aren't duplicated. I found that adding in an extra line to allow for advanced image-formatting did the trick, changing the code to:
// Clean-up.
$init['extended_valid_elements'] = array('img[class|style|src|border=0|alt|title|hspace|vspace|width|height|align|onmouseover|onmouseout|name]');
$init['extended_valid_elements'] = array_unique($init['extended_valid_elements']);
$init['extended_valid_elements'] = array_unique($init['extended_valid_elements']);
This may have been solved in one of the dev versions, or I'm happy to submit a patch, if you can point me in the right direction for where this code should go. Seems like it should be included int he tinyMCE settings in WYSIWYG as the basic/advanced image buttons ship with the editor as standard.
Also, it looks like the code that the settings for $init['extended_valid_arguments'] is set to an empty array, when iterating through the user plugins. Might make sense for a global setting to include the standard tags used by the buttons that TinyMCE ships with.
Happy to help, if I can. Hope this is useful.
Toodle Pip
| Comment | File | Size | Author |
|---|---|---|---|
| #9 | 372165_tinymce_exnteded_valid_elements.patch | 2.29 KB | hefox |
| #2 | patch-wysiwyg-20090214.txt | 707 bytes | toodlepip |
Comments
Comment #1
sunYes, please supply a patch.
Comment #2
toodlepip commentedPatch is attatched. This is my first attempt at creating one, so hope this is correct. Needs to be applied to:
wysiwyg/editors/tinymce.incfile. Hope it helps.Comment #3
sunSorry, but
in unacceptable. This patch probably breaks a bunch of other editor plugins, including the Image Assist plugin. A real fix should not be very hard (as long as you understand the syntax of those extended valid element definitions).
Comment #4
toodlepip commentedSorry sun, I'm new to this, so forgive the newbie errors.
I wasn't sure whereabouts this code should go, as the Advanced Image feature is part of the core TinyMCE editor. The initialisation of $init seemed like the right place to put it, but the extended_valid_arguments element is reset when the info is called in from the plugins.
Should this code go into a separate file in the plugins directory, or wysiwyg.plugins.inc? Or somewhere else? Sorry if these are dumb questions.
Comment #5
sunThe location of the changes in your patch was (approximately) correct. However, your patch (even) starts with a comment that says "Nasty hack" -- Nasty hacks work for your particular use-case, but not for everyone else. The Advanced image plugin already defines the extended_valid_elements property. In your initial post you outlined that another plugin is also defining this poperty for the same HTML tag and TinyMCE uses the "wrong" definition (for the other plugin), which renders the Advanced image plugin non-functional. The proper solution for this bug is merge all extended_valid_elements definitions correctly, so if two plugins are defining it for the same HTML tag, the allowed (valid) attributes are appropriately merged into one element definition.
Comment #6
toodlepip commented@sun Thanks for the feedback. Have done some more reading and my use case seems to be the same as the #287025: IMCE_Wysiwyg API bridge module which effectively solves the issue. I reckon this issue can be closed, if you're cool with it.
Comment #7
toodlepip commentedComment #8
sunComment #9
hefox commentedPatch assumes extended_valid_elements is array('font[face|size|color|style]', 'span[class|align|style]') and not array('font[face|size|color|style],span[class|align|style]') and thus changes where it is done like the later.