I have tried using code but still can not upload webp image to listing

As the topic mentioned, I have tried this snippet, but it still didn’t work for me to upload webp format photo. Please help!


add_filter(
	'hivepress/v1/models/listing',
	function( $model ) {
		$formats =  ['webp'];
		$model['fields']['images']['formats'] = array_merge($model['fields']['images']['formats'], $formats);
		return $model;
	},
1000
);

​I hope this is helpful to you.

1 Like

This code works perfectly. :+1:

Hello! Thanks for your prompt reply! But this code still does not work for me :smiling_face_with_tear:, when I click the “Select images” in the “Add listing” page, those photos in webp format can not be selected. I captured the screen of the steps I made, could you please tell me what exactly the problem is? Thank you.



This code works fine in the frontend, but it doesn’t work in the backend because the HivePress plugin currently doesn’t accept WebP format for uploads. Hopefully, HivePress will address this limitation in a future update. :blush: If you’re trying to upload WebP images while creating or editing a listing in the frontend, it should work fine.

1 Like

Got it! Thank you so much for your detailed explanation! :blush:

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.