Forum Replies Created
-
AuthorPosts
-
Paul Tsung
ParticipantHi Long,
Maybe I am not understanding correctly. But I created a test field group with this code.
add_filter( 'rwmb_meta_boxes', 'create_watch_fields' ); function create_watch_fields( $meta_boxes ) { $post_id = null; if ( isset( $_GET['post'] ) ) { $post_id = intval( $_GET['post'] ); } elseif ( isset( $_POST['post_ID'] ) ) { $post_id = intval( $_POST['post_ID'] ); } $meta_boxes[] = [ 'title' => 'Watch Details', 'id' => 'watch-details', 'post_types' => 'watch', 'fields' => [ [ 'name' => 'Name', 'id' => 'watch-name', 'type' => 'text', ], [ 'name' => 'Watch Video', 'id' => 'watch-video', 'type' => 'file', 'upload_dir' => WP_CONTENT_DIR . '/watchvideos/' . $post_id . '/', 'max_file_uploads' => 1, 'force_delete' => true, ] ] ]; return $meta_boxes; };In the postmeta table, I see the meta_value with the URL only.
And then I use rwmb_meta( 'watch-video' ) to get the meta object.
There is a path key in the return object with the custom path.
{"http:\/\/lwpdigicomp.local\/wp-content\/watchvideos\/417\/sample.mp4":{"icon":"
","name":"sample.mp4","path":"\/Users\/paultsung\/Local Sites\/lwpdigicomp\/app\/public\/wp-content\/watchvideos\/417\/sample.mp4","url":"http:\/\/lwpdigicomp.local\/wp-content\/watchvideos\/417\/sample.mp4","title":"sample","edit_link":""}}So is this not suppose to happen when I use a custom upload folder for the file field?
Thanks.
Paul Tsung
ParticipantHi Long,
Thank you for getting back to me.
It's interesting because it looks like I get the path key when I use a custom folder with the file field when not using it within a group.
So does that mean that if I am using it in a group, I can only get the URL and need to derived the path from the URL? The reason I need the path is because I want to do some processing on the file after it is uploaded to the server.
Thanks.
-
AuthorPosts