[Solved] WPForo Advanced Attachments: images in original size

  

2
Topic starter

I am using WPForo for my forum. Also, I use wpForo Advanced Attachments: https://gvectors.com/product/wpforo-advanced-attachments/

The problem is that the images uploaded are resized... and are blurry

I want them shown in the size they were uploaded (keep the original size).

How can I do it? 

1 Answer
2

Go to: [YOU RSITE]/wp-content/plugins/wpforo-advanced-attachments/includes/class.wpForoAttachUploadHandler.php

and modify: class.wpForoAttachUploadHandler.php with the following code:

1. Modify imagemagick_create_scaled_image:

protected function imagemagick_create_scaled_image( $file_name, $version, $options ) {
    list($file_path, $new_file_path) = $this->get_scaled_image_file_paths($file_name, $version);
    
    // Instead of resizing, just copy the file
    if ($file_path !== $new_file_path) {
        return copy($file_path, $new_file_path);
    }

    return true;
}

2. Modify imagick_create_scaled_image:

protected function imagick_create_scaled_image( $file_name, $version, $options ) {
    list($file_path, $new_file_path) = $this->get_scaled_image_file_paths($file_name, $version);
    
    // Skip resizing logic, just copy the original image
    if ($file_path !== $new_file_path) {
        return copy($file_path, $new_file_path);
    }

    return true;
}

3. Modify handle_image_file (if necessary) If there is any image processing in this function, ensure it is bypassed as well:

protected function handle_image_file($file_path, $file) {
    // Skip any resizing or processing
    return;
}

These changes ensure that the image retains its original height and width during the upload process by disabling the resizing steps in your image processing functions.

Share: