feat: imageCenter field

This commit is contained in:
2025-09-25 15:22:06 -04:00
parent 8f893623ca
commit ed479312fa
2 changed files with 23 additions and 0 deletions

View File

@@ -0,0 +1,22 @@
<?php
// Add 'imageCenter' field to MediaItem type
add_action( 'graphql_register_types', 'ccat_register_image_center_graphql_field' );
function ccat_register_image_center_graphql_field() {
register_graphql_field(
'MediaItem',
'imageCenter',
array(
'type' => 'String',
'description' => 'Image center point for cropping (e.g., "50% 50%")',
'resolve' => function ( $source, $args, $context, $info ) {
if ( empty( $position = get_post_meta( $source->databaseId, 'theiaSmartThumbnails_position', true ) ) ) {
return null;
}
$x = round( $position[0], 4 );
$y = round( $position[1], 4 );
return "$x% $y%";
},
)
);
}