Last active
August 9, 2017 09:16
-
-
Save artboard-studio/efa7a7bdd09b4ebf57be to your computer and use it in GitHub Desktop.
Initials Thumbnail for WordPress
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Capital Framework Initials Thumbnail | |
.cfw-initails-thumbnail { | |
background: #d8d8d8; | |
color: #333; | |
width: 45px; | |
height: 45px; | |
display: inline-block; | |
border-radius: 50%; | |
margin-right: 15px; | |
text-align: center; | |
line-height: 45px; | |
font-size: 16px; | |
text-transform: uppercase; | |
font-weight: 300; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Takes a string and gets the initials of the first two words and puts them in a span | |
* @param string|$the_title_string The text from wich the initials will be taken | |
* @return The initials in a span with a class of .cfw-initails-thumbnail | |
*/ | |
function cfw_initails_thumbnail($the_title_string, $initials_limit) { | |
$cfw_thumb_initials = preg_split("/[\s,_-]+/", $the_title_string, $initials_limit ); | |
$the_initial = ""; | |
foreach ( $cfw_thumb_initials as $w ) { | |
$the_initial .= $w[0]; | |
} | |
return '<span class="cfw-initails-thumbnail">'.$the_initial.'</span>'; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment