Skip to content

Commit

Permalink
Gettext update and .bmp error message
Browse files Browse the repository at this point in the history
  • Loading branch information
greenbrook committed Jul 27, 2013
1 parent d5239c5 commit ff46da5
Showing 1 changed file with 15 additions and 7 deletions.
22 changes: 15 additions & 7 deletions resize.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ function matthewruddy_image_resize( $url, $width = NULL, $height = NULL, $crop =
global $wpdb;

if ( empty( $url ) )
return new WP_Error( 'no_image_url', __( 'No image URL has been entered.' ), $url );
return new WP_Error( 'no_image_url', __( 'No image URL has been entered.','wta' ), $url );

// Get default size from database
$width = ( $width ) ? $width : get_option( 'thumbnail_size_w' );
Expand Down Expand Up @@ -72,6 +72,10 @@ function matthewruddy_image_resize( $url, $width = NULL, $height = NULL, $crop =
$ext = $info['extension'];
$name = wp_basename( $file_path, ".$ext" );

if ( 'bmp' == $ext ) {
return new WP_Error( 'bmp_mime_type', __( 'Image is BMP. Please use either JPG or PNG.','wta' ), $url );
}

// Suffix applied to filename
$suffix = "{$dest_width}x{$dest_height}";

Expand Down Expand Up @@ -168,7 +172,7 @@ function matthewruddy_image_resize( $url, $width = NULL, $height = NULL, $crop =
global $wpdb;

if ( empty( $url ) )
return new WP_Error( 'no_image_url', __( 'No image URL has been entered.' ), $url );
return new WP_Error( 'no_image_url', __( 'No image URL has been entered.','wta' ), $url );

// Bail if GD Library doesn't exist
if ( !extension_loaded('gd') || !function_exists('gd_info') )
Expand Down Expand Up @@ -202,6 +206,10 @@ function matthewruddy_image_resize( $url, $width = NULL, $height = NULL, $crop =
$ext = $info['extension'];
$name = wp_basename( $file_path, ".$ext" );

if ( 'bmp' == $ext ) {
return new WP_Error( 'bmp_mime_type', __( 'Image is BMP. Please use either JPG or PNG.','wta' ), $url );
}

// Suffix applied to filename
$suffix = "{$dest_width}x{$dest_height}";

Expand All @@ -227,7 +235,7 @@ function matthewruddy_image_resize( $url, $width = NULL, $height = NULL, $crop =
// Get the current image dimensions and type
$size = @getimagesize( $file_path );
if ( !$size )
return new WP_Error( 'file_path_getimagesize_failed', __( 'Failed to get $file_path information using "@getimagesize".', 'rivasliderpro'), $file_path );
return new WP_Error( 'file_path_getimagesize_failed', __( 'Failed to get $file_path information using "@getimagesize".','wta'), $file_path );
list( $orig_width, $orig_height, $orig_type ) = $size;

// Create new image
Expand Down Expand Up @@ -270,19 +278,19 @@ function matthewruddy_image_resize( $url, $width = NULL, $height = NULL, $crop =
// Check the image is the correct file type
if ( IMAGETYPE_GIF == $orig_type ) {
if ( !imagegif( $new_image, $dest_file_name ) )
return new WP_Error( 'resize_path_invalid', __( 'Resize path invalid (GIF)' ) );
return new WP_Error( 'resize_path_invalid', __( 'Resize path invalid (GIF)','wta' ) );
}
elseif ( IMAGETYPE_PNG == $orig_type ) {
if ( !imagepng( $new_image, $dest_file_name ) )
return new WP_Error( 'resize_path_invalid', __( 'Resize path invalid (PNG).' ) );
return new WP_Error( 'resize_path_invalid', __( 'Resize path invalid (PNG).','wta' ) );
}
else {

// All other formats are converted to jpg
if ( 'jpg' != $ext && 'jpeg' != $ext )
$dest_file_name = "{$dir}/{$name}-{$suffix}.jpg";
if ( !imagejpeg( $new_image, $dest_file_name, apply_filters( 'resize_jpeg_quality', 90 ) ) )
return new WP_Error( 'resize_path_invalid', __( 'Resize path invalid (JPG).' ) );
return new WP_Error( 'resize_path_invalid', __( 'Resize path invalid (JPG).','wta' ) );

}

Expand All @@ -297,7 +305,7 @@ function matthewruddy_image_resize( $url, $width = NULL, $height = NULL, $crop =
// Get some information about the resized image
$new_size = @getimagesize( $dest_file_name );
if ( !$new_size )
return new WP_Error( 'resize_path_getimagesize_failed', __( 'Failed to get $dest_file_name (resized image) info via @getimagesize' ), $dest_file_name );
return new WP_Error( 'resize_path_getimagesize_failed', __( 'Failed to get $dest_file_name (resized image) info via @getimagesize','wta' ), $dest_file_name );
list( $resized_width, $resized_height, $resized_type ) = $new_size;

// Get the new image URL
Expand Down

0 comments on commit ff46da5

Please sign in to comment.