Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
oakesjosh committed Jun 12, 2024
2 parents d77bd9e + d9e91c6 commit 946e42f
Show file tree
Hide file tree
Showing 3 changed files with 63 additions and 43 deletions.
5 changes: 5 additions & 0 deletions includes/blocks/class-kadence-blocks-image-block.php
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,11 @@ public function build_css( $attributes, $css, $unique_id, $unique_style_id ) {
}
}

// Object position
if ( isset( $attributes['imagePosition'] ) && $attributes['imagePosition'] ) {
$css->add_property( 'object-position', $attributes['imagePosition'] );
}

// Caption Font
if ( ! isset( $attributes['showCaption'] ) && isset( $attributes['captionStyles'] ) && is_array( $attributes['captionStyles'] ) && is_array( $attributes['captionStyles'][0] ) ) {
$caption_font = $attributes['captionStyles'][0];
Expand Down
4 changes: 4 additions & 0 deletions src/blocks/image/block.json
Original file line number Diff line number Diff line change
Expand Up @@ -332,6 +332,10 @@
},
"overlayBlendMode": {
"type": "string"
},
"imagePosition": {
"type": "string",
"default": ""
}
},
"supports": {
Expand Down
97 changes: 54 additions & 43 deletions src/blocks/image/image.js
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ import {
CopyPasteAttributes,
GradientControl,
BackgroundTypeControl,
KadenceFocalPicker,
} from '@kadence/components';

export default function Image({
Expand Down Expand Up @@ -178,6 +179,7 @@ export default function Image({
overlayOpacity,
overlayBlendMode,
globalAlt,
imagePosition,
} = attributes;

const previewURL = dynamicURL ? dynamicURL : url;
Expand Down Expand Up @@ -660,49 +662,57 @@ export default function Image({
onChange={(value) => setAttributes({ useRatio: value })}
/>
{useRatio && (
<SelectControl
label={__('Size Ratio', 'kadence-blocks')}
value={ratio}
options={[
{
label: __('Landscape 4:3', 'kadence-blocks'),
value: 'land43',
},
{
label: __('Landscape 3:2', 'kadence-blocks'),
value: 'land32',
},
{
label: __('Landscape 16:9', 'kadence-blocks'),
value: 'land169',
},
{
label: __('Landscape 2:1', 'kadence-blocks'),
value: 'land21',
},
{
label: __('Landscape 3:1', 'kadence-blocks'),
value: 'land31',
},
{
label: __('Landscape 4:1', 'kadence-blocks'),
value: 'land41',
},
{
label: __('Portrait 3:4', 'kadence-blocks'),
value: 'port34',
},
{
label: __('Portrait 2:3', 'kadence-blocks'),
value: 'port23',
},
{
label: __('Square 1:1', 'kadence-blocks'),
value: 'square',
},
]}
onChange={(value) => setAttributes({ ratio: value })}
/>
<>
<SelectControl
label={__('Size Ratio', 'kadence-blocks')}
value={ratio}
options={[
{
label: __('Landscape 4:3', 'kadence-blocks'),
value: 'land43',
},
{
label: __('Landscape 3:2', 'kadence-blocks'),
value: 'land32',
},
{
label: __('Landscape 16:9', 'kadence-blocks'),
value: 'land169',
},
{
label: __('Landscape 2:1', 'kadence-blocks'),
value: 'land21',
},
{
label: __('Landscape 3:1', 'kadence-blocks'),
value: 'land31',
},
{
label: __('Landscape 4:1', 'kadence-blocks'),
value: 'land41',
},
{
label: __('Portrait 3:4', 'kadence-blocks'),
value: 'port34',
},
{
label: __('Portrait 2:3', 'kadence-blocks'),
value: 'port23',
},
{
label: __('Square 1:1', 'kadence-blocks'),
value: 'square',
},
]}
onChange={(value) => setAttributes({ ratio: value })}
/>

<KadenceFocalPicker
url={url ? url : ''}
value={imagePosition ? imagePosition : 'center center'}
onChange={(value) => setAttributes({ imagePosition: value })}
/>
</>
)}
{showMaxWidth && (
<ResponsiveRangeControls
Expand Down Expand Up @@ -1526,6 +1536,7 @@ export default function Image({
: undefined) +
')'
: undefined,
objectPosition: imagePosition ? imagePosition : undefined,
}}
onError={() => onImageError()}
onLoad={(event) => {
Expand Down

0 comments on commit 946e42f

Please sign in to comment.