HivePress 1.7.31 ignores images max_files snippet

HivePress 1.7.31 ignores images max_files snippet

The following snippet worked in 1.7.30:

add_filter(

 'hivepress/v1/models/listing',

 function( $model ) {

 $model\['fields'\]\['images'\]\['max_files'\] = 100;

 return $model;

 },

 1000

);

After updating to 1.7.31 the upload limit is back to 10 files and the form shows:

“Only up to 10 files can be uploaded.”

Any ideas how to fix?

Thanks for your message — our team will reply shortly.

In the meantime, you can also get instant help from our AI Assistant, familiar with all the docs and solutions we’ve shared over the years.

Hi,

Please make sure that the snippet is added correctly (as a PHP snippet instead of CSS, and it shouldn’t contain backslashes):

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

		return $model;
	},
	1000
);

Also, please refresh the page after adding the snippet because the number of images is also set in the HTML field attribute. I tested the snippet locally with 15 files and once I added it and refreshed the page, the uploader allowed adding 15 instead of 10 (default limit) files.

Hope this helps

Same problem 1.7.31 ….. is there a solution already?

If possible, please send a link to your site (you can also send it privately via support@hivepress.io) – at the moment we can’t reproduce this issue locally and on the demo site, maybe this is something specific to the website setup.

Rollback to 1.7.30 and the problem is over. I hope there comes a solution.

I found solution with new snippet

add_filter(
'hivepress/v1/fields/attachment_upload',
function( $args ) {
    $args['max_files'] = 100;

    return $args;
},
1000
);

I would recommend to add this feature to HivePress plugin :slight_smile:

I become this error with your snippet

Undefined constant “‘hivepress”

Please note that this snippet sets the limit for any attachment field in any form, not just the listing images, but since there’s no multiple attachments option for other fields yet, it may be used as a temporary workaround.

Please make sure that you added it as a PHP, not JS code snippet. I also fixed the formatting in the reply, you can try copying it again as there were converted quotes in the code.

Thanks, now it works as a “temporary workaround“
I’m happy with it :slightly_smiling_face:

Just a follow-up with the solution:

It turned out that this specific request was related to image uploads from the backend. The previous snippet works for the frontend uploader, so it does not affect image uploads made from the backend.

To increase the image limit beyond 10 images per listing when using the backend uploader, please use the following snippet: Change the maximum number of images per listing #hivepress #listings · GitHub

1 Like