Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
No matter what I try I can't get font changes to work. Here are my custom Filter HTML settings right now:
<a> <em> <style> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd> <object> <embed> <img> <a href> <p> <br> <div> <font> <span>
yet font colors and sizes never work unless i activate full HTML.
Could someone who has TinyMCE working good paste over their Filtered HTML allow list?
Thanks so much, If i get this working on my own I'll post here.
Comments
Comment #1
sunWell, it's possible that TinyMCE tries to define the font by using a style="" attribute, which may be removed by HTML filter (core) or contrib HTML sanitization filter.
1) What is the actual markup that TinyMCE produces? (Either look via "Devel load" or directly in the database {node}.body)
2) Which HTML filter do you have installed and enabled? Does it also happen if you disable the filter?
Comment #2
DjC4 CreditAttribution: DjC4 commentedYeah, it is defining by using style.
Is there a way to change it to FONT or allow font style tags to be used?
Comment #3
DjC4 CreditAttribution: DjC4 commentedIssue solved.
Inside the configuration for TinyMCE there is a new setting that says:
Last time i used TinyMCE this wasn't there. I have no idea how I missed it before.
if you un-check this you can use classic TinyMCE font tags to format with (as opposed to style tags which are blocked by filter HTML).
NOTE: You will have to go back to any posts you made while you had this option checked, clear the formating and re-do your fonts,size and color under the new font tag setting.
Comment #4
sunAha! Good to know.
a) Does this setting/feature of using style tags actually make sense in Drupal then? (Should we remove it? Was it the built-in "HTML filter" of Drupal core that stripped those style attributes?)
b) Could you add this information summarized to the FAQ issue (in the queue), please? (using the same style like the last entries there)
Comment #5
DjC4 CreditAttribution: DjC4 commentedYes I'll paste this into the FAQ.
I suppose the style command is handy if only admins are using the Rich Text on a site. This way it would be much easier to re-theme all your content. So I guess the option is nice (once you know it exists).
Comment #7
tjtj CreditAttribution: tjtj commentedI tried this, but no matter if the font box is checked or not, I always get style tags and not font tags with Drupal 7 and TinyMCE. So I think somehow this fix got left on the floor for version 7.
Comment #8
TwoDTinyMCE will always use styling like
<span style="...">selected text</span>
instead of<font ...>selected text</font>
when creating new content - this i by design since it produces XHTML. The<font>
is not valid in XHTML, and the setting mentioned in #3 will make TinyMCE convert existing<font>
tags to spans with style attributes as well. Without that setting checked TinyMCE will leave existing font tags alone, but won't create new ones. At least not unless you've got a really old version.To not filter out styles, I recommend using WYSIWYG Filter module. It's a replacement for the simple "HTML Filter"-filter and allows you to build a much more detailed whitelist of tags, attributes and style properties.
Btw, "needs work" only applies if there's a patch, see http://drupal.org/node/156119
No patch/fix was comitted for this issue.
Comment #9
tjtj CreditAttribution: tjtj commentedBut the font buttons all produce span tags, so how would the user create font tags instead? WYSIWYG Filter solves this, but you will have to search the Issues to get a build for Drupal 7.
Thanks,
Jim
Comment #10
TwoDYes, using spans is normal since
<font>
tags are not allowed at all in XHTML so the editor will not create them. If font changes are applied to an entire paragraph, the editor will not insert spans but apply the styling to the p tag instead.WYSIWYG Filter module will not make the editor create font tags for you (it can't change what the editor does at all, only what is filtered out during Drupal's rendering), but using it instead of the standard HTML Filter will make it possible for Drupal to render the inline styles.
Somehow forcing the editor to output font tags would make the markup invalid.
Comment #11
tjtj CreditAttribution: tjtj commentedFiltered HTML removes all inserted images. The pointer to the image itself is removed, and all I am left with is the tag.
I tried the version of WSYIWYG Filter for Drupal 7. The instructions for its use are not clear. If I enable it, all the TinyMCE editing buttons disappear, so this is not a feasible solution for my customers. I hope this is something that I screwed up in the WSYIWYG Filter configuration. Please advise.
Thanks,
Jim
Comment #12
TwoDThe WYSIWYG Filter module configuration does not affect Wysiwyg module at all. WYSIWYG Filter only creates a new input/text filter that runs code during rendering while Wysiwyg module runs all its code during editing. I can't see how enabling or configurating that module would remove all buttons you've enabled for the editor.
Note that the later versions of Wysiwyg module do not display any buttons unless you've explicitly enabled them in the editor profile.
When you say "The pointer to the image itself is removed, and all I am left with is the tag.", is that when you view the rendered node?
If it still looks ok in the editor, this is just a misconfigured WYSIWYG Filter. First, make sure the old "HTML Filter" is completely disabled so it won't interfere. Second, you'll need to change the configuration of WYSWYG Filter - using the syntax described under "Syntax tips" - so that img tags are allowed and they in turn are allowed to have src attributes as well as alt and title attributes.
The line for that tag would be something like this:
img[src|alt|title]
.If you need to apply styling to your img tags (or other tags), you'll also add "style" after "title" above and check some of the "Style properties" checkboxes.
None of these settings affect how the editor(s) behave, only what Drupal will actually keep in the markup when it's being rendered. Keep in mind that users could simply disable the editor and type any code into your fields otherwise.
Comment #13
tjtj CreditAttribution: tjtj commentedI figured this out. I put the filtered html first, and then used wild cards in the tags. I.e., img[*]. Then it works properly.
Thanks for the help,
Jim