Skip to content

Commit 62fcc6a

Browse files
authored
Merge pull request #111 from wp-graphql/fix/#106-oembed-field-support
fix: oembed field type returns embed instead of URL entered to the field
2 parents 31c56c6 + 2fcef1a commit 62fcc6a

File tree

3 files changed

+14
-3
lines changed

3 files changed

+14
-3
lines changed

src/FieldConfig.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -286,6 +286,7 @@ public function should_format_field_value( string $field_type ): bool {
286286
'select',
287287
'wysiwyg',
288288
'repeater',
289+
'oembed',
289290
];
290291

291292
return in_array( $field_type, $types_to_format, true );
@@ -440,7 +441,7 @@ public function resolve_field( $root, array $args, AppContext $context, ResolveI
440441
*
441442
* @param mixed $value
442443
* @param array $field_config The ACF Field Config for the field being resolved
443-
* @param mixed $root The Root node or obect of the field being resolved
444+
* @param mixed $root The Root node or object of the field being resolved
444445
* @param mixed $node_id The ID of the node being resolved
445446
*/
446447
return apply_filters( 'wpgraphql/acf/field_value', $prepared_value, $field_config, $root, $node_id );

tests/wpunit/FieldTypes/OembedFieldTest.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,10 @@ public function tearDown(): void {
1717
parent::tearDown();
1818
}
1919

20+
public function get_clone_value_to_save(): string {
21+
return 'https://twitter.com/wpgraphql/status/1115652591705190400';
22+
}
23+
2024
public function get_field_type(): string {
2125
return 'oembed';
2226
}
@@ -33,4 +37,9 @@ public function get_acf_clone_fragment(): string {
3337
';
3438
}
3539

40+
public function get_expected_clone_value() {
41+
return wp_oembed_get( $this->get_clone_value_to_save(), [ 'width' => 550 ] );
42+
43+
}
44+
3645
}

tests/wpunit/PostObjectFieldsTest.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -544,8 +544,9 @@ public function testQueryOembedField() {
544544
'name' => 'oembed_field',
545545
]);
546546

547-
$expected = 'https://twitter.com/wpgraphql/status/1115652591705190400';
548-
update_field( 'oembed_field', $expected, $this->post_id );
547+
$input = 'https://twitter.com/wpgraphql/status/1115652591705190400';
548+
update_field( 'oembed_field', $input, $this->post_id );
549+
$expected = wp_oembed_get( $input, [ 'width' => 550 ] );
549550

550551
$query = '
551552
query GET_POST_WITH_ACF_FIELD( $postId: Int! ) {

0 commit comments

Comments
 (0)