$w =
$size['width'
];
$h =
$size['height'
];
$ratio =
_image_get_preview_ratio( $w,
$h );
$w2 =
max( 1,
$w *
$ratio );
$h2 =
max( 1,
$h *
$ratio );
if ( is_wp_error( $img->
resize( $w2,
$h2 ) ) ) { return false;
} return wp_stream_image( $img,
$post->post_mime_type,
$post_id );
}/**
* Restores the metadata for a given attachment.
*
* @since 2.9.0
*
* @param int $post_id Attachment post ID.
* @return stdClass Image restoration message object.
*/
function wp_restore_image( $post_id ) {