0

I have used thie resize method to resize image and its working fine but only the problem which i am facing right now is that is not resizing image with extension in capital letter like JPG,JPEG,GIP. the same image will be resized if we just change the extension from JPG to jpg the image will be resized. Please let me know how can i fix this.

$image = wp_get_image_editor($targetFile); 
if ( ! is_wp_error( $image ) ) {
 //$image->rotate( 90 );
  $image->resize( 300, 400, false );
  $image->save($targetFile); 
}
1

This happens because capital letter like JPG,JPEG,GIP are not the allowed mime types in wordpress.

For list of allowed mime types check the codex.

Now to get your code work, you need to add the capital mime types into the allowed mime types.

You can do it by adding the following code in your active theme's functions.php file

add_filter( 'mime_types', 'wpse125310_mime_types' );
function wpse125310_mime_types( $output ) {
    $output['JPG'] = 'image/JPG';
    $output['JPEG'] = 'image/JPEG';
    $output['GIP'] = 'image/GIP';

    return $output;
}

You can add other mimetypes to the above too.

|improve this answer|||||

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.