• Resolved jonkristen

    (@jonkristen)


    Hi,

    I’m making a used marker in our store where users can upload info and images via a wpforms post submission form. The product listing is made by an Elementor Loop template. I’ve chosen the woocommerce thumbnail size in the template, but images are not resized because they are not recognized as product images I assume.
    Is there a way to acheive that these images are resized?
    I have added the media upload filter.

    Pwd: strienew

    Jon Kristen

    The page I need help with: [log in to see the link]

Viewing 6 replies - 1 through 6 (of 6 total)
  • Plugin Author Nabil Lemsieh

    (@nlemsieh)

    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

    Thread Starter jonkristen

    (@jonkristen)

    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

    Plugin Author Nabil Lemsieh

    (@nlemsieh)

    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

    Thread Starter jonkristen

    (@jonkristen)

    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.
    Plugin Author Nabil Lemsieh

    (@nlemsieh)

    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

    Plugin Author Nabil Lemsieh

    (@nlemsieh)

    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

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Use image smart image resize for post library’ is closed to new replies.