How to replace flag text with custom icon? I am using flag and views to show a "like" flag in a view. The machine name of my flag is "like". I want to replace the text of the flag with a heart icon. When it is not flagged, it is empty and when flagged, it is filled with red color as happens generally. I do not want to show icon besides text and neither I want to transform my flag into a button. If you have used instagram, you must know that there is a heart icon for a "like" flag. When someone clicks it, it becomes red. Like when you favorite a tweet on twitter.

I found this code, but do not know how to use it for my case. I am not sure whether it is the right code to use.

function Your_theme_preprocess_flag(&amp;$vars) {
  $class = ($vars['action'] == 'flag') ? '&lt;i class="fa fa-heart-o"&gt;   &lt;/i&gt;' : '&lt;i class="fa fa-heart"&gt;&lt;/i&gt;';
  $vars['link_text'] = $class;
  $title_wishlist = ($vars['action'] == 'flag') ? 'Add to wishlist' : 'Remove from wishlist';
  $vars['link_title'] = $title_wishlist;
}


Note: I know I have to put it in template.php file of my theme. If you see the post, I took this code from there, but I have multiple flags on my site for example "like" "follow" "bookmark" etc etc. So I want to use this code for the "like" flag. How can i do that
I am also interested in learning how to add any icon other than heart and any flag I want.
This code is needed in your template.php and a font-icon lybrary added like this one: http://fontawesome.io/icons/ There is a module for that to