Focal point might be 0, 0. Checking x and y with isset() fails if value is 0.
This code works:
/**
* Get css object-position attribute by focal point
*
* @param $focal_point array
*
* @return string
*/
function get_focal_point_style( $focal_point ) {
if ( ! $focal_point || ! is_array( $focal_point ) ) {
return '';
}
$focal_point_x = array_key_exists( 'x', $focal_point ) ? $focal_point['x'] * 100 : false;
$focal_point_y = array_key_exists( 'y', $focal_point ) ? $focal_point['y'] * 100 : false;
if ( $focal_point_x !== false && $focal_point_y !== false ) {
return "object-position: {$focal_point_x}% {$focal_point_y}%";
}
return '';
}