File/image input field does not work when in group
- This topic has 18 replies, 2 voices, and was last updated 7 years, 7 months ago by
Truong Giang.
-
AuthorPosts
-
August 12, 2017 at 1:16 AM #6604
ludovic.meyer
ParticipantHello,
I took your image field demo and put it in a group. The image upload does not work anymore.
Can you fix this ?
Regards,
$meta_boxes[] = array( 'post_types' => array( 'post' ), 'title' => esc_html__( 'Image Upload Demo', 'your-prefix' ), 'fields' => array( array( 'name' => '', 'id' => 'test_group', 'type' => 'group', 'fields' => array( array( 'id' => 'image', 'name' => esc_html__( 'Image', 'your-prefix' ), 'type' => 'image', 'force_delete' => false, 'max_file_uploads' => 2, ), ), ), ), );
August 12, 2017 at 1:42 AM #6605ludovic.meyer
ParticipantThis fix is pretty important for me. If you can fix it quickly you would be awesome.
August 14, 2017 at 3:26 PM #6631Truong Giang
ParticipantHi there,
Can you use the
image_advanced
field before we can solve this problem?Update: Oh. Sorry. I have just read your topic about uploading image in frontend. We are checking this problem. Please wait.
August 14, 2017 at 3:40 PM #6632ludovic.meyer
ParticipantHello,
I have a problem with both configuration (image or image_upload), but you saw that 🙂
https://support.metabox.io/topic/image-upload-does-not-work-with-mb-frontend-submission/
Thank you for your support,
August 15, 2017 at 10:40 AM #6639Truong Giang
ParticipantHi,
Can you give me your email? I'll send you the fixed code. We still have some works with MB Group so we will update it later.
Please make sure that you are using MB Group 1.2.10 before use fixed code.UPDATE: We have just released MB Group 1.2.11. Please update it.
Thanks.
August 16, 2017 at 4:17 PM #6657ludovic.meyer
ParticipantHi,
Will try MB Group 1.2.11.
Thank you,
August 18, 2017 at 12:46 AM #6680ludovic.meyer
ParticipantHello,
I tested MB Group 1.2.11 today.
That does not work, and the problems are multiples.
1. If I select an image, then save the post. If i save the post again (even without touching anything), the image is no more linked to the field (and stays in the media library as an orphan)
See https://screencast-o-matic.com/watch/cbjbbpl77B
Behaviour is the same in front or back2. If the group is clonable (and only 1 file allowed per field), the behaviour is weird. All medias seems to go in the first group instead of one per group after save.
See https://screencast-o-matic.com/watch/cbjbbGl77W
After a second save, all images are gone (see 1)Regards,
August 19, 2017 at 9:00 AM #6700Truong Giang
ParticipantHi,
I got the problem. We are fixing it ASAP.
Thank you.
August 21, 2017 at 6:17 AM #6707ludovic.meyer
ParticipantOk,
Keep me up to date, please
Thank you
August 23, 2017 at 4:45 PM #6735ludovic.meyer
ParticipantHello,
Do you have any news ? I'm taking a quick fix if you have one.
My client is supposed to begin to use the forms today.Regards,
August 24, 2017 at 9:49 AM #6750Truong Giang
ParticipantHi there,
Can you give me your email address? I will give you a quick fix version. This version works if the image field is in level 1 of group (like your case).
Thank you.
August 24, 2017 at 3:02 PM #6752ludovic.meyer
ParticipantAugust 24, 2017 at 5:23 PM #6753Truong Giang
ParticipantHi there,
Sorry about this. There are some problems so we can't send you the hotfix. You can use image_advanced field and add
upload_files
capability for users. The code below add that cap for subscriber:/** * Allow the media uploader work on specific pages */ function mb_allow_contributor_uploads() { if ( is_admin() ) { return; } $path = isset( $_SERVER['REQUEST_URI'] ) ? $_SERVER['REQUEST_URI'] : ''; if ( ! $path || '/page-slug' != $path ) { return; } /** * Replace 'subscriber' with the required role to update, can also be contributor */ $subscriber = get_role( 'subscriber' ); // This is the only cap needed to upload files. $subscriber->add_cap( 'upload_files' ); } add_action( 'init', 'mb_allow_contributor_uploads' );
August 24, 2017 at 6:27 PM #6754ludovic.meyer
ParticipantHello,
As i told you in the other thread, my subscribers already have the upload_files capability but they can't upload.
See https://support.metabox.io/topic/image-upload-does-not-work-with-mb-frontend-submission/#post-6600I prefer wait for a fix (or a quick fix). I just hope it will be released soon 🙂
Please tell me when it's ok,
August 25, 2017 at 8:36 AM #6758Truong Giang
ParticipantHave you tried with the code above? I tested and it works, with some CSS fix. I removed page checking. Please try again:
/** * Allow the media uploader work on specific pages */ function mb_allow_subscriber_uploads() { if ( is_admin() ) { return; } /** * Replace 'subscriber' with the required role to update, can also be contributor */ $subscriber = get_role( 'subscriber' ); // This is the only cap needed to upload files. $subscriber->add_cap( 'upload_files' ); } add_action( 'init', 'mb_allow_subscriber_uploads' );
-
AuthorPosts
- You must be logged in to reply to this topic.