Skip to content

Commit

Permalink
Merge pull request #65 from humanmade/fix-gravity-param
Browse files Browse the repository at this point in the history
Fix gravity parameter construction
  • Loading branch information
roborourke authored Feb 18, 2021
2 parents 945ce40 + 5b9059a commit c939b87
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions inc/class-tachyon.php
Original file line number Diff line number Diff line change
Expand Up @@ -352,6 +352,9 @@ public static function filter_the_content( $content ) {
}

// Set the gravity from the registered image size.
// Crop weight array values are in x, y order but the value `westsouth` will
// cause Sharp to error and Tachyon to return a 404, it needs to be `southwest`
// so we reverse the crop array to y, x order.
if ( 'resize' === $transform && isset( $size ) && $size !== 'full' && array_key_exists( $size, $image_sizes ) && is_array( $image_sizes[ $size ]['crop'] ) ) {
$args['gravity'] = implode( '', array_map( function ( $v ) {
$map = [
Expand All @@ -362,7 +365,7 @@ public static function filter_the_content( $content ) {
'right' => 'east',
];
return $map[ $v ];
}, $image_sizes[ $size ]['crop'] ) );
}, array_reverse( $image_sizes[ $size ]['crop'] ) ) );
}
} elseif ( false !== $width ) {
$args['w'] = $width;
Expand Down Expand Up @@ -624,7 +627,7 @@ public function filter_image_downsize( $image, $attachment_id, $size ) {
'right' => 'east',
];
return $map[ $v ];
}, $image_args['crop'] ) );
}, array_reverse( $image_args['crop'] ) ) );
}
}

Expand Down

0 comments on commit c939b87

Please sign in to comment.