function _focal_point_guess_default in Focal Point 7
Make a best guess for the initial value of the focal point of the given file.
If possible, guess at the initial value of the focal point. If all else fails, return 50,50.
Parameters
int $fid: The fid of the image file entity in question.
Return value
string Ex. 45,23.
3 calls to _focal_point_guess_default()
- focal_point_effect_crop_data in ./
focal_point.effects.inc - Compile the necessary data for the image crop effect.
- focal_point_widget_process in ./
focal_point.module - Field widget process function.
- _focal_point_form_append_focal_point_preview in ./
focal_point.module - Append the focal point preview field to file edit forms.
File
- ./
focal_point.module, line 503
Code
function _focal_point_guess_default($fid) {
$method = variable_get('focal_point_default_method', '');
if ($method && ($file = file_load($fid)) && ($image = image_load($file->uri))) {
$methods = focal_point_get_default_method_info();
if (isset($methods[$method])) {
if ($coords = call_user_func($methods[$method]['callback'], $image)) {
// Convert coordinates to a percents of the image dimensions.
list($x, $y) = $coords;
$x = intval($x / $image->info['width'] * 100);
$y = intval($y / $image->info['height'] * 100);
return $x . ',' . $y;
}
}
}
// Default to the center of the image.
return FOCAL_POINT_DEFAULT;
}