Skip to content

Commit 505312d

Browse files
committed
change: upload detects parent episode when using WP REST API
1 parent 1662fc5 commit 505312d

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

lib/modules/wordpress_file_upload/wordpress_file_upload.php

+7-1
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,13 @@ public function custom_media_upload_dir($upload, $force_override = false)
9393
$podlove_subdir = $this->get_subdir();
9494

9595
$id = isset($_REQUEST['post_id']) ? (int) $_REQUEST['post_id'] : 0;
96-
$parent = $id ? get_post($id)->post_parent : 0;
96+
97+
if (isset($_REQUEST['post'])) {
98+
// when uploaded via POST /wp/v2/media
99+
$parent = (int) $_REQUEST['post'];
100+
} else {
101+
$parent = $id ? get_post($id)->post_parent : 0;
102+
}
97103

98104
if ($force_override || 'podcast' == get_post_type($id) || 'podcast' == get_post_type($parent)) {
99105
$upload['subdir'] = $podlove_subdir;

0 commit comments

Comments
 (0)