Skip to content

Commit 90d6ca5

Browse files
committed
phpcs
1 parent 6ec2c08 commit 90d6ca5

File tree

2 files changed

+13
-11
lines changed

2 files changed

+13
-11
lines changed

src/Type/ObjectType/MediaDetails.php

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,15 @@ public static function register_type() {
1515
[
1616
'description' => __( 'File details for a Media Item', 'wp-graphql' ),
1717
'fields' => [
18-
'width' => [
18+
'width' => [
1919
'type' => 'Int',
2020
'description' => __( 'The width of the mediaItem', 'wp-graphql' ),
2121
],
22-
'height' => [
22+
'height' => [
2323
'type' => 'Int',
2424
'description' => __( 'The height of the mediaItem', 'wp-graphql' ),
2525
],
26-
'file' => [
26+
'file' => [
2727
'type' => 'String',
2828
'description' => __( 'The filename of the mediaItem', 'wp-graphql' ),
2929
'resolve' => static function ( $media_details ) {
@@ -35,17 +35,17 @@ public static function register_type() {
3535
'description' => __( 'The path to the mediaItem relative to the uploads directory', 'wp-graphql' ),
3636
'resolve' => static function ( $media_details ) {
3737
// Get the upload directory info
38-
$upload_dir = wp_upload_dir();
38+
$upload_dir = wp_upload_dir();
3939
$relative_upload_path = wp_make_link_relative( $upload_dir['baseurl'] );
40-
40+
4141
if ( ! empty( $media_details['file'] ) ) {
4242
return path_join( $relative_upload_path, $media_details['file'] );
4343
}
44-
44+
4545
return null;
4646
},
4747
],
48-
'sizes' => [
48+
'sizes' => [
4949
'type' => [
5050
'list_of' => 'MediaSize',
5151
],
@@ -87,7 +87,7 @@ public static function register_type() {
8787
return ! empty( $sizes ) ? $sizes : null;
8888
},
8989
],
90-
'meta' => [
90+
'meta' => [
9191
'type' => 'MediaItemMeta',
9292
'description' => __( 'Meta information associated with the mediaItem', 'wp-graphql' ),
9393
'resolve' => static function ( $media_details ) {

src/Type/ObjectType/MediaSize.php

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,12 @@ public static function register_type() {
2828
'description' => __( 'The path of the file for the referenced size (default size is full)', 'wp-graphql' ),
2929
'resolve' => static function ( $image ) {
3030
if ( ! empty( $image['ID'] ) ) {
31-
$original_file = get_attached_file( absint( $image['ID'] ) );
32-
if ( ! empty( $original_file ) && ! empty( $image['file'] ) ) {
31+
$original_file = get_attached_file( absint( $image['ID'] ) );
32+
$attachment_url = wp_get_attachment_url( $image['ID'] );
33+
34+
if ( ! empty( $original_file ) && ! empty( $image['file'] ) && ! empty( $attachment_url ) ) {
3335
// Return the relative path for the specific size
34-
return path_join( dirname( wp_make_link_relative( wp_get_attachment_url( $image['ID'] ) ) ), $image['file'] );
36+
return path_join( dirname( wp_make_link_relative( $attachment_url ) ), $image['file'] );
3537
}
3638
} elseif ( ! empty( $image['file'] ) ) {
3739
return wp_make_link_relative( $image['file'] );

0 commit comments

Comments
 (0)