I don’t like the default smilies in WP. There, I said it. They’re old and busted, so I use the smilies_src
to replace them with nicer ones. Recently it came to my attention how old and busted my cute PNGs looked on my iPad and any retina capable computer, so I fiddled around and decided SVG graphics were the way to go. They scale well, and they work on all modern browsers, yay!
Oh, wait, IE 8 is not a modern browser and it’s pretty common out there… In fact my old job still uses it on a lot of PCs. And so does at least one user on this site (actually 5, and one more uses IE 6, for crying out loud!) so I came up with this:
// Move Smilies add_filter('smilies_src','my_smilies_src', 1, 10); function my_smilies_src($img_src, $img, $siteurl) { $img = rtrim($img, "gif"); // Remove GIF if ( strpos( $_SERVER['HTTP_USER_AGENT'], 'MSIE 8' ) || strpos( $_SERVER['HTTP_USER_AGENT'], 'MSIE 7' ) ) { $type='png'; } else { $type='svg'; } return 'http://domain.com/images/smilies/'.$img.$type.''; }
That said, I wish we had more modern smilies available for WP. Finding a set that look okay (like the ones I have here) that are also retina capable are not easy. I could use user agents to go the other way, checking if the visitor was on a ‘new’ iPad or iPhone and show them retina that way, but to the best of my knowledge, there’s no way (yet) to do it so that a retina MacBook also gets the nicer view. With that in mind, I went just with SVG, which scale naturally and meet all of my needs.
By the way, thank Otto for the smilies filter. You can use it for normal filtering too:
add_filter('smilies_src','ipstenu_smilies_src', 1, 10); function ipstenu_smilies_src($img_src, $img, $siteurl){ $img = rtrim($img, "gif"); return $siteurl.'/images/smilies/'.$img.'png'; }
That’s what I use here.