Skip to content
This repository has been archived by the owner on Feb 23, 2024. It is now read-only.

Commit

Permalink
Use the focal point on the frontend display
Browse files Browse the repository at this point in the history
  • Loading branch information
ryelle committed Apr 29, 2019
1 parent 2fc1f56 commit fd41a32
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions assets/php/class-wgpb-block-featured-product.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ class WGPB_Block_Featured_Product {
'align' => 'none',
'contentAlign' => 'center',
'dimRatio' => 50,
'focalPoint' => false,
'height' => false,
'mediaId' => 0,
'mediaSrc' => '',
Expand Down Expand Up @@ -118,6 +119,14 @@ public static function get_styles( $attributes, $product ) {
$style .= sprintf( 'min-height:%dpx;', intval( $attributes['height'] ) );
}

if ( isset( $attributes['focalPoint'] ) && 2 === count( $attributes['focalPoint'] ) ) {
$style .= sprintf(
'background-position: %s%% %s%%',
$attributes['focalPoint']['x'] * 100,
$attributes['focalPoint']['y'] * 100
);
}

return $style;
}

Expand Down

0 comments on commit fd41a32

Please sign in to comment.