plupload_image only working for first instance in functions.php file
- This topic has 2 replies, 2 voices, and was last updated 3 years, 1 month ago by
Christopher Reichert.
-
AuthorPosts
-
April 5, 2022 at 10:59 AM #35465
Christopher Reichert
ParticipantI am using the latest metabox
Meta Box - Version 5.6.2
Meta Box AIO - Version 1.15.8
MB Group - Version 1.3.13In my functions.php file (in use for many years now) I have this recurring code (excerpt):
// META BOXES - PERSON META
add_filter( 'rwmb_meta_boxes', 'person_stuff_meta_boxes' );
function person_stuff_meta_boxes( $meta_boxes ) {$prefix = 'person_stuff_';
$meta_boxes[] = array(
'id' => 'personData',
'title' => __( 'Person Data', 'person_stuff_' ),
'post_types' => array( 'post', 'page' ),
'context' => 'normal',
'priority' => 'high',
'autosave' => true,'fields' => array(
// Full Name
array(
'name' => __( 'Full Name with suffixes', 'person_stuff_' ),
'id' => "{$prefix}FullName",
'type' => 'text',
'placeholder' => __( 'John Smith, SM \'84, PhD \'94', 'person_stuff_' ),
),
// Profile pic
array(
'name' => __( 'Profile photo', 'person_stuff_' ),
'id' => "{$prefix}profilePhoto",
'type' => 'plupload_image',
'max_file_uploads' => 1,
),
array(
'type' => 'divider',
),// Company Logo
array(
'name' => __( 'Company Logo', 'person_stuff_' ),
'id' => "{$prefix}companyImage",
'type' => 'plupload_image',
'max_file_uploads' => 1,
),Until recently, each instance of plupload_image allowed for an upload field to appear where we could upload an image...one for the person, another for a company logo, etc.
Now, only the first instance of plupload_image works. So in this case, the company logo field only gets the label but no field into which to dump an image.
Here are two screenshots...show how if you reverse the Company Name and Profile Photo, only the first gets the opportunity to upload.
https://mitcio2022.artisanovens.com/wp-content/uploads/2022/04/missingfield.jpg
and
https://mitcio2022.artisanovens.com/wp-content/uploads/2022/04/reordered.pngI have rolled back WP to 5.7.6 and PHP and moved hosting services to test this, but no luck.
Any suggestions?
April 5, 2022 at 6:54 PM #35475Long Nguyen
ModeratorHi Christopher,
The field type
plupload_image
is deprecated, please use the field typeimage_advanced
or other image fields likeimage_upload
to upload images. Read more on the documentation
https://docs.metabox.io/fields/image-upload/
https://docs.metabox.io/fields/image-advanced/April 5, 2022 at 9:51 PM #35480Christopher Reichert
Participantty! That worked.
In case it helps others, here is the old and new code:
OLD CODE:
// Company Logo OLD CODE DEPRECATED PLUPLOAD_IMAGE
// array(
// 'name' => __( 'Company Logo', 'person_stuff_' ),
// 'id' => "{$prefix}companyImage",
// 'type' => 'plupload_image',
// 'max_file_uploads' => 1,
// ),NEW CODE:
// Company Logo
array(
'id' => '{$prefix}companyImage',
'name' => 'Company Logo', 'person_stuff_',
'type' => 'image_upload',// Delete file from Media Library when remove it from post meta?
// Note: it might affect other posts if you use same file for multiple posts
'force_delete' => false,
// Maximum file uploads.
'max_file_uploads' => 1,
// Image size that displays in the edit page.
'image_size' => 'thumbnail',
), -
AuthorPosts
- You must be logged in to reply to this topic.