Files
cultureat-bak/wp-content/themes/ccat/includes/graphql/image-center.php

23 lines
668 B
PHP

<?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%";
},
)
);
}