Maximum Image upload set to 1 but vendors still upload 5 or 10 images

I’m using below snippet code for limit maximum images uploading to max 1 but vendors still upload 5 or 10 images.

I’ve try it, if vendor upload images one by one the snippet works fine and don’t let vendors upload more than 1

But if they choose several photos same time during first upload, this snippet is not work fine and let users to upload any amount of images and they don’t limit to 1 and can uploading 5 or 10

I’ve try it in new listing and edit listing. On both palce it’s not working fine.

add_filter(
	'hivepress/v1/models/listing',
	function( $model ) {
		$model['fields']['images']['max_files'] = 1;

		return $model;
	},
	1000
);

If you want to set the restriction to only 1 image then please try this code snippet as a temporary solution

add_filter(
	'hivepress/v1/models/listing',
	function( $model ) {
		$model['fields']['images']['max_files'] = 1;
		$model['fields']['images']['multiple'] = false;

		return $model;
	},
	100
);

Thanks, I’ve check, vendors now can upload only one image and multiple image upload issues is solved.

But now when vendors upload 1 image, it’s uploaded successfully in backend but users in frontend can’t see that image and list published without any image!

Would you please solve this new issue?

You can try this snippet instead:

add_filter(
	'hivepress/v1/forms/listing_update',
	function( $model ) {
		$model['fields']['images']['max_files'] = 1;
		$model['fields']['images']['multiple'] = false;

		return $model;
	},
	100
);

Please note that it may require further customizations, this is just a suggestion.

I am using the same code, seems to work when I limit to 2,3,5 images, but doesnt work if I want to raise from 10 to 30 for example… seems that there is other script that limit the uploads to 10 pictures.

Hi,

Please try using this code snippet

<?php
add_filter(
	'hivepress/v1/models/listing',
	function( $model ) {
		$model['fields']['images']['max_files'] = 123;

		return $model;
	},
	100
);