Created
March 25, 2015 12:37
-
-
Save mcgregormedia/abab4239d7294af5878e 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 retina_support_create_images( $file, $width, $height, $crop = false ) { | |
if ( $width || $height ) { | |
$resized_file = wp_get_image_editor( $file ); | |
if ( ! is_wp_error( $resized_file ) ) { | |
$filename = $resized_file->generate_filename( $width . 'x' . $height . '@2x' ); | |
$resized_file->resize( $width * 2, $height * 2, $crop ); | |
$resized_file->save( $filename ); | |
$info = $resized_file->get_size(); | |
return array( | |
'file' => wp_basename( $filename ), | |
'width' => $info['width'], | |
'height' => $info['height'], | |
); | |
} | |
} | |
return false; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment