Skip to content

Instantly share code, notes, and snippets.

@mcgregormedia
Created March 25, 2015 12:37
Show Gist options
  • Save mcgregormedia/abab4239d7294af5878e to your computer and use it in GitHub Desktop.
Save mcgregormedia/abab4239d7294af5878e to your computer and use it in GitHub Desktop.
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