Hi all,
I’m trying to add the gallery function to Vendors, I’ve successfully done it by keeping all the fields as “images” but this removes the ability to upload a Featured Image / Vendor Profile Picture.
So to keep the ability to upload featured images, I have created the below code, this below code allows me to add on the same gallery function that Listings have to Vendors (uploading through the backend and through the frontend), except it doesn’t “save”/“store” the images to the Vendor profile. The images are uploaded to the media gallery though.
// Add Vendor Images Field
add_filter(
'hivepress/v1/models/vendor/fields',
function( $fields ) {
$fields['vendor_images'] = [
'label' => hivepress()->translator->get_string( 'images' ),
'caption' => hivepress()->translator->get_string( 'select_images' ),
'type' => 'attachment_upload',
'multiple' => true,
'max_files' => 10,
'formats' => [ 'jpg', 'jpeg', 'png' ],
'_model' => 'attachment',
'_relation' => 'one_to_many',
];
return $fields;
}
);
// Add Vendor Images to Vendor Update
add_filter(
'hivepress/v1/forms/vendor_update',
function( $form ) {
if ( isset( $form['fields'] ) ) {
$form['fields']['vendor_images'] = [
'_order' => 10,
];
}
return $form;
}
);
// Add Vendor Images Meta Box
add_filter(
'hivepress/v1/meta_boxes',
function( $meta_boxes ) {
$meta_boxes['vendor_photos'] = [
'title' => "Gallery Images",
'screen' => 'vendor',
'model' => 'vendor',
'fields' => [
'vendor_images' => [
'caption' => hivepress()->translator->get_string( 'select_images' ),
'type' => 'attachment_upload',
'multiple' => true,
'max_files' => 10,
'formats' => [ 'jpg', 'jpeg', 'png' ],
'_order' => 10,
],
],
];
return $meta_boxes;
}
);
Any help would be great, thanks!