You can try to crop the image in places you want manually using the WP_Image_Editor
class. Here is a simple example:
1 2 3 4 5 6 7 8 9 10 11 12 |
$image = 'http://karunshakya.com.np/wp-content/themes/twentyeleven/images/headers/lanterns.jpg'; $img_size = getimagesize($image); // Return an implementation that extends <tt>WP_Image_Editor</tt> $img_process = wp_get_image_editor( $image ); if ( ! is_wp_error( $img_process ) ) { //$img_process->resize( 1920, 661, array( 'left', 'top' ) ); $img_process->crop( 0, 0, $img_size[0], $img_size[1], 600, 339 ); $img_process->save( $image ); $img_process->set_quality( 100 ); } |
If you like this question & answer and want to contribute, then write your question & answer and email to freewebmentor[@]gmail.com. Your question and answer will appear on FreeWebMentor.com and help other developers.