Skip to content

Instantly share code, notes, and snippets.

@jawngee
Created September 29, 2017 18:35
Show Gist options
  • Save jawngee/eba64296c7cc4bc13bf4631e947c8b78 to your computer and use it in GitHub Desktop.
Save jawngee/eba64296c7cc4bc13bf4631e947c8b78 to your computer and use it in GitHub Desktop.
Passing detected faces to imgix
<?php
// not tested
// would go into your theme's functions.php
add_filter('ilab-imgix-filter-parameters',function($params, $size, $id, $meta){
if (isset($meta['faces']) && is_array($meta['faces'])) {
$firstFace = $meta['faces'][0];
$rect = $firstFace['BoundingBox'];
list($width, $height, $left, $top) = array_values($rect);
$params['not_sure_what_it_is'] = "$left,$top,$width,$height";
}
return $params;
}, 10, 4);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment