I’m just probably (for me it’s in line 468, but that may be caused by script updates) looking at this error. I get this error message on the Media List page where WordPress shows a 60×60 image preview, using a 150×150 source file:

The error occurs when calling function get_smartcrop_focus_attr(2601, array(60,60))
. Note the array as second parameter. This second parameter is checked in is_image_size_cropped()
, which returns false, thus allowing the function get_smartcrop_focus_attr
to proceed to line 468:
$this->focus_cache[ $id ][ $size ] = $ret_val;
$size
still contains array(60, 60)
which causes the warning (and possibly some other unexpected results).
As a simple solution I went to make sure I have a valid array key:
$size_str = is_array($size) ? implode('::', $size) : $size;
… and then use $size_str
in all three locations where $size was referenced as a key for focus_cache.
private function get_smartcrop_focus_attr( $id, $size ) {
$size_str = is_array($size) ? implode('::', $size) : $size;
// check cache
if( isset( $this->focus_cache[ $id ] ) && isset( $this->focus_cache[ $id ][ $size_str ] ) ) {
return $this->focus_cache[ $id ][ $size_str ];
}
if( !$this->is_image_size_cropped( $size ) ) {
if( get_post_meta( $id, '_wpsmartcrop_enabled', true ) == 1 ) {
$focus = get_post_meta( $id, '_wpsmartcrop_image_focus', true );
if( $focus && is_array( $focus ) && isset( $focus['left'] ) && isset( $focus['top'] ) ) {
$ret_val = json_encode( array(
round( intval( $focus['left'] ), 2 ),
round( intval( $focus['top' ] ), 2 ),
) );
// load into cache
if( !isset( $this->focus_cache[ $id ] ) ) {
$this->focus_cache[ $id ] = array();
}
$this->focus_cache[ $id ][ $size_str ] = $ret_val;
return $ret_val;
}
}
}
return false;
}