You should probably have something inside the i-tags - for example instead of
<i class="icon-sun"> </i>
TinyMCE tends to strip most "empty tags" - there are a couple of exceptions like
do not get stripped but tags like
vanish immediately from source. I'm not sure if the reason for stripping is in validation code (valid_elements) or somewhere else but it is easy to add for example that non-breaking space to such elements.
I ran into similar issue for the first time when we tried to create "empty img tags" with certain class as a placeholder for different math images/graphs etc.
It might be easy to create also a filter (and editor plugin) for this kind of icons so that code like /delimiter/sun/delimiter/ could be converted to <i class="icon-sun"></i> in content
That HAS to be done.
And so..here is the link to a beta that does just that.
just install this as a filter in Moodle. To embed icons enywhere you have a text editor just use square brackets around the stand icon name.
this filter works as is but I am still trying to figure out how I can add a variable to it so you can specify a size as using the tinymce size styling does not seem to work.
Nice. For large icons you could look for the extra classes on this page:
So examples would be:
[icon-camera-retro icon-large] [icon-camera-retro icon-2x] [icon-camera-retro icon-3x] [icon-camera-retro icon-4x]
The icon-fixed-width one is probably very useful too, and support for rotating and spinning would be a fun demo.
Because http://fortawesome.github.io/Font-Awesome/examples/ has lots of variations it might be easiest to allow any input and just replace delimiters with i tags - I am not sure if [...] is the best option but attached a zip package with a tiny modification that allows code like
[icon-spinner icon-spin icon-4x]
and outputs it like
<i class="icon-spinner icon-spin icon-4x"></i>
I changed the search row to
$search = "()is";
and callback to
$embed = '<i class=".$matches."></i>';
What is that code for load_global_config() doing? It was getting config of emoticons filter ... is it necessary at all?
For those "complex" examples you can use also code like
<span class="icon-stack icon-4x"> [icon-camera] [icon-ban-circle icon-stack-base]</span>
Getting better all the time... yes, it should.
The only requirement then is that first class must start with icon- and not for example with "pull-left".
yes, I really like this string. Provides a specific starting to call to start the filter but allows for a variety of options to be added. I have updated the filter in Github now.
Unless anyone has any really issues with the current form I plan to release it in the plugins DB next week.
Here however is my "challenging thought for the week" (music blares)
So a user loves the idea of font awesome icons but does not have a theme that includes it. Could we load FontAwesome from the CDN with a filter? Of course I don't want to pull in the CDN every tie an icon is called. Just once per page where needed. Any ideas?
edit: or maybe IE will, boo hiss!
...outdated text editor
Talking about TinyMCE 4 it's not a question about version of editor - TinyMCE 4 strips empty tags just as well as TinyMCE 3, actually even more.
If you test on your site with Essential theme and tinymce 3 the following tags
2) <i class="icon-twitter-sign"> </i>
3) <span class="icon-twitter-sign"></span>
4) <span style="font-family: FontAwesome;" ></span>
5) <i class="icon-twitter-sign"></i>
1) is rendered with Julian's filter
2) is rendered ok
3) is rendered ok (TinyMCE 3 does not strip this)
4) is rendered ok
5) TinyMCE 3 strips empty tag
If you test the same on http://www.tinymce.com/tryit/basic.php (TinyMCE4)
1) would work
2) TinyMCE changes i tags to em tags but <em class="icon-twitter-sign"> </em> still works ! (Tested)
3) TinyMCE 4 strips empty span tags
4) would work
5) TinyMCE 4 strips empty i tags
Summa summarum Mary's workaround is ok, adding non-breaking space to tags like i, span, em,... makes them "safe" for any version of tinymce so it does not matter if you use <i class="icon-twitter-sign"> </i> or <span class="icon-twitter-sign"> </span> or <em class="icon-twitter-sign"> </em>
<i class="icon-twitter-sign"> </i> is simply the sortest workaround for TinyMCE 4 - and if we use a filter we need to use only classes and delimiters.
See also http://www.tinymce.com/presentation/index.html#/13
TinyMCE 4 is still in beta for a while, we are working on updating the documentation and fixing issues as they arise.
If Petr would say tomorrow that all themes of moodle 2.7 are going to use different layout model, different file structure, all the theme code needs to be rewritten... it would be close to situation where Stuart is saying that a few rows of code is enough to "write" an "editor" - it isn't. Editor without necessary plugins is not an editor - it's just as good as plain textarea, a tool that is not validating input properly is not a good editor and the cleanup that TinyMCE is doing is just based on the validation rules in it - that can in some cases prevent a lot of rubbish going to the HTML code...
Doesn't seem liek this got added to the DB yet - any chance of that happening soon? Since 2.5 I've been trying to move away from git installed plugins to auth'd plugins from the DB to use Moodle's auto-updater.
In short I got busy and forgot.
It has been added and is now awaiting approval.
I have also put some detailed documentation on icon usage as well as how to setup the CDN through Moodle settings in a MoodleDoc. Please feel free to add to it if you wish.
Crikey! I am stoked.
Julian, you are absolutely bril!!
Thanks Frankie. Glad you like it. I just love that this all happened from a random comment in a forum post.
I have written a more detailed forum post on it now here: http://moodleman.net/articles/using-fontawesome-moodle/
And have set up a demo course here: http://features.demo.moodle.com.au/course/view.php?id=35
1. revel in the wonders of Font Awesome,
2. to celebrate installing the Font Awesome filter on my Moodle site,
3. and to celebrate your past, current and future achievements of the Essential theme,
I've decided to do this!
I've created two photomosaics of your images using the Font Awesome icons. This took me almost 30% of a whole day's work. I had to figure out how to automatically convert the Font Awesome icons into PNG files using Python (the toughest part!). Then I had to batch convert 378 PNG files into JPG format (only after a tough web search). Finally, I used AndreaMosaic to create the final mosaics using a combination of 2,000 repeating JPG images of the icons (the easiest part!). Enjoy.
One more...for fun!
Best viewed from a distance of 3 feet away from the monitor.
P.S., if it helps anyone, I've also created a zip file that has the PNG and JPG images of all 378 Font Awesome icons. I doubt if you can find the icons in image format anywhere on the Internet. Of course, Font Awesome, as a graphical font by itself has an advantage over the image format. Anyway for what it's worth, here's the link:
Many thanks to David Gandy for this font!
I follow your instructions but it does not work.
First I add the Link (look at the screenshot)
Then I install the filter.
But if i write for example
nothing happens. I use Essential 2.6 (2013100800) and Moodle 2.5.2+ (Build: 20131011)
What can I do?
I found my mistake. I have forgotten do enable the filter.
Julian, this is great! Now for the next discussion (version 1.1?):
Should the full font-awesome stack be moved into this text filter and then any themes that want to use it (say to replace nav-tree icons) mark this plugin as a dependency?
The reason being that if the theme has font-awesome core assets, not the text-filter, then switching themes will "break" this text filter. e.g. this filter needs a font-awesome enabled theme as a dependency. Just seems backwards, or rather, needlessly divided.
either way I'll be installing this ASAP