Last active
February 3, 2018 03:05
-
-
Save davidsword/70506506ffef3eee9d9a9d49f0af9949 to your computer and use it in GitHub Desktop.
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
<? | |
function handsomefox_get_thumbnail($image_url, $size = 'thumbnail') { | |
$size = (in_array($size,array('thumbnail','medium','large','full'))) | |
? strtolower($size) : 'thumbnail'; | |
if ($size == 'full') | |
return $image_url; | |
//break down the file url string | |
$ext = pathinfo($image_url, PATHINFO_EXTENSION); | |
$file = str_replace('.'.$ext,'',$image_url); | |
$ext = strtolower($ext); | |
//get the ap width height | |
$width = get_option($size.'_size_w'); | |
$height = get_option($size.'_size_h'); | |
//replace "jpeg" w wordpress "jpg" | |
$ext = ($ext == 'jpeg') ? 'jpg': $ext; | |
//reconstruct url | |
$thumb = "{$file}-{$width}x{$height}.{$ext}"; | |
return $thumb; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment