Forum Replies Created
-
AuthorPosts
-
February 17, 2022 at 9:56 PM in reply to: Media Post Parent Not Attached On CPT With Certain Field Types #33964
Armand Morin
ParticipantThank you for the response. After watching your video and seeing the video and images attached, I started doing some testing.
The reason is they are not attaching is simply because in supports if 'Thumbnail' is not added, most files or images will not be attached to the post.
Once I added 'Thumbnail' in supports in the custom post type, everything is not attached. I'm not sure if this is a WordPress thing or Metabox, I'm thinking WordPress
Armand Morin
ParticipantThank you for your responses. I do appreciate them, but we are not quite understanding each other as to what the issue is.
I've made a video showing you the difference in the database.
https://www.youtube.com/watch?v=bjun2ljc4IAArmand Morin
ParticipantOk, after a HUGE amount of testing I figured it out exactly what the problem is with the media attachment issue.
I created a metabox with every option of upload. I tested with an image and a video.
My first test results are here...
https://ibb.co/C7BXYCSAs you can see image_input (shown as select by mistake), file_input, file_advanced, image_advanced, single_image, and video are shown as UNATTACHED.
Seeing your results were not the same as mine, I tried to figure out what was different. The difference is, I was using a Custom Post Type and you were either using a metabox on a "post" or "page".
So I changed all metaboxes in my test to display on a "page" and I reran all the tests again.
Here are my second results...
https://ibb.co/Qns93NQAs you can now see, when the same fields are uploaded via a "page" metabox everything works perfectly as it should and every upload is attached to the post as it should be.
So the problem is image_input, file_input, file_advanced, image_advanced and single_image fields DO NOT attach to the post if you are using a custom post type.
So this is what needs to be fixed.
I hope this makes sense.
Armand Morin
ParticipantI am currently using similar code to this article you posted... https://www.isitwp.com/remove-featured-image-deleting-post/, modified to remove custom post type attachments upon deletion.
The issue is this...
1.) In my custom post type, I am uploading an image and a video along with other information.
2.) When I look in the Media Library the image and the video uploaded is not attached to any post it is shown as "Unattached".
3.) The only time this does not happen is if I change the fields I am using to the "image" field or the "file" field. When using either of these fields the files will show in the Media Library as "Attached".So even using code such as you suggest in the link above, if I am using fields such as "video", "file_input", "file_advanced" or "file_upload" the code will not work because the if you use any of these fields, the file will upload as "Unattached" in the media library.
Shouldn't using any of these fields result in the media being attached to that specific post?
See my point?
Armand Morin
ParticipantUpdate... I went through same tests, this time with the Frontend Submissions Plugins installed rather than using it through. Metabox AIO. The results where still the same.
The only two upload fields that work properly are... file and image uploads. These two the media upload is attached to the post in the Media Library.
The other upload fields that I have listed above.. DO NOT attach to the post and are listed as "Unattached".
Armand Morin
ParticipantI added force_delete to my fields and same result.
I did some more testing on various upload fields. Most are not working correctly. They are not attaching themselves to the post.
Here are my results...
Field Type Attached/Unattached
image - Attached
video - Unattached
file - Attached
file_input - Unattached
file_advanced - Unattached
file_upload - UnattachedThe ones mark Unattached are not attaching themselves to the post. I change the above metabox information and only changed the fields and then looked into the media library to see if the video or image is attached or not.
Armand Morin
ParticipantI changed the field to file_upload and the video and the image is still not attached.
I am using this via the Frontend Submission plugin if that helps.
Here's a sample of my metabox.
$meta_boxes[] = [ 'title' => 'Video Information', 'post_types' => 'ctavideos', 'id' => 'ctavideos', 'hidden' => array( array( 'ctavideos_kind_of_player_select', '!=', 'standard' ), array( 'ctavideos_kind_of_player_select', '!=', 'ctaplayer' ), ), 'class' => 'fieldwrapper', 'columns' => 12, 'fields' => [ [ 'type' => 'heading', 'name' => 'Video Details', 'desc' => 'Select your video and upload it to our system. Your video should be in an mp4 format in order to display correctly. If it is not in an mp4 then you must convert it first.', ], [ //'name' => 'Video Upload', 'placeholder' => 'Click the "Select" button to upload your video.', 'id' => 'ctavideos_video', 'type' => 'file_upload', 'columns' => 11, ], [ //'name' => 'Poster Image', 'placeholder' => 'Click the "Select" button below to upload an image.', 'id' => 'ctavideos_posterimage', 'type' => 'file_upload', 'image_size' => 'medium', 'columns' => 11, ], ] ];Armand Morin
ParticipantI found out how to redirect to the same post by adding edit the shortcode.
Armand Morin
ParticipantHere's the code I am using. Like I said it works perfectly with the individual plugin, but not with AIO.
$meta_boxes[] = [ 'title' => 'What Kind of Player', 'post_types' => 'ctavideos', 'id' => 'ctavideos_decision_player_metabox', 'class' => 'fieldwrapper', 'fields' => [ [ 'type' => 'heading', 'name' => 'What kind of player do you want to create?', 'desc' => 'Choose the kind of player you want to create by selecting your option below.', ], [ 'name' => 'Select The Type of Player', 'id' => 'ctavideos_kind_of_player', 'type' => 'radio', 'options' => array( 'standard' => 'Standard Player', 'ctaplayer' => 'Call To Action', 'playlistplayer' => 'Playlist Player', ), //'inline' => true, 'columns' => 12, ], ] ]; $meta_boxes[] = [ 'title' => 'Video Playlist', 'post_types' => 'ctavideos', 'id' => 'ctavideos_playlist_metabox', 'hidden' => array( 'ctavideos_kind_of_player', '!=', 'playlistplayer' ), 'class' => 'fieldwrapper', 'columns' => 12, 'fields' => [ [ 'type' => 'heading', 'name' => 'Video Playlist', 'desc' => 'Enter the details below for your videos and information you want in the playlist.', ], [ 'id' => 'playlist_group_id', 'type' => 'group', 'clone' => true, 'add_button' => 'Add Another Video', 'sort_clone' => true, 'group_title' => 'Playlist Video Details', 'collapsible' => 'false', 'fields' => array( array( 'name' => 'Upload Your Video', 'id' => 'ctavideos_playlist_videos', 'type' => 'file_input', 'placeholder' => 'Enter the url of your call to action.', ), array( 'name' => 'Link Text', 'id' => 'ctavideos_playlist_link_text', 'type' => 'text', 'placeholder' => 'Enter the button text. ie.) Click Here', ), array( 'name' => 'Poster Image', 'id' => 'ctavideos_playlist_poster', 'type' => 'file_input', ), ), ], ] ];Armand Morin
ParticipantI turned off Conditional Logic in Metabox AIO and uploaded the individual plugin and everything work fine. So it's something with Metabox AIO that's missing for Conditional Logic.
-
AuthorPosts