A helper function that resizes images using WordPress' built in wp_get_image_editor function.
get_image_thumb( $src, $opts );
- $src - Image src (url or path)
- $opts (optional) - Resize options
array (
"w" => 500,
"h" => 200,
"q" => 100, // Quality
"crop" => false // Crop image
);
array(
"w" => PHP_INT_MAX, // Won't resize if image width is smaller than default width
"h" => PHP_INT_MAX, // Won't resize if image height is smaller than default height
"q" => 95,
"crop" => false
);
$id = get_post_thumbnail_id( get_the_ID() );
$src = wp_get_attachment_image_src( $id, $size );
$src = $src[0];
$newImage = get_image_thumb( $src, array( "w" => 50, "h" => 50, "q" => 75, "crop" => true ) );
$newImage = get_image_thumb( $src, "w=50&h=50&q=75&crop=true" );