Hi @jonkristen
By default, images uploaded on the front end are not resized. To enable it, you can add this code snippet to your theme functions.php:
add_filter('wp_sir_process_frontend_upload', '__return_true');
Let me know how it goes.
Best,
Nabil
Hi again,
Got this error:
Warning: Invalid argument supplied for foreach() in /home/striestr/public_html/woocommerce/wp-content/plugins/wpforms-post-submissions/class-post-submissions.php on line 264
This is line 264:
foreach ( $fields[ $id ][‘value_raw’] as $file ) {
Best regards,
Jon Kristen
Hi @jonkristen
Thank you for the update.
As per the error source, can you confirm if it occurs when you deactivate the Smart Image Resize plugin?
Best regards,
Nabil
Hi,
Did a new test removing the filter from functions.php, and I still got the error message in debug, so it´s most likely not related to Smart Image Resize(hadn´t noticed it before I added the code snippet, so I thought there was a connection.)
Anyway, the images from frontend upload are still not resized.
I suspect it has to do with them being fetched as post featured images, and not product images.
Any ideas?
Best regards,
Jon Kristen
-
This reply was modified 3 years, 10 months ago by jonkristen.
Hi @jonkristen
There is chance that the plugin doesn’t regenerate thumbnails when an image is uploaded, to explicitly regenerate them, add this code:
add_action('add_attachment', function($attachment_id){
$full_path = get_attached_file( $attachment_id );
require_once ABSPATH . 'wp-admin/includes/image.php' ;
$data = wp_generate_attachment_metadata( $attachment_id, $full_path );
if (!is_wp_error($data) && !empty($metadata) ) {
wp_update_attachment_metadata( $attachment_id, $data );
}
});
add_filter('wp_sir_process_frontend_upload', '__return_true');
If it still doesn’t work, please, get in touch at support[at]sirplugin.com to assist you further.
Best,
Nabil
Obviously, WPForms Post Submissions attaches uploaded image to a new post. Since Smart Image Resize processes only product-images by default. You need to allow post-images resize by adding this code snippet:
add_filter('wp_sir_resize_post_type', function($post_types){
if( ! is_array($post_types)){
$post_types = (array) $post_types;
}
$post_types[] = 'post';
return $post_types;
});
Best,
Nabil