Notifications
Clear all

[Solved] Keep origina image sizes

7 Posts
2 Users
1 Likes
624 Views
Posts: 8
Customer
Topic starter
(@venkat-mangudi)
Member
Joined: 3 years ago

Can you tell me where this option is and how to add that hook? 

With my limited knowledge, I changed the file 

 

wpforo-advanced-attachments/wpf-third-party/file-uploader/UploadHandler.php

and modified the following line 

 $image_quality = isset($options['jpeg_quality']) ?
                    $options['jpeg_quality'] : 100; //Removed compression - 

 

But that did not upload the full size image, it still reduced a 2.38MB file to 208kb or so.

6 Replies
Posts: 4173
 Tom
Admin
(@tomson)
Famed Member
Joined: 9 years ago

@venkat-mangudi,

Please don't do any changes in the code directly and revert all your changes.

When you upload an image it's cooped and the thumbnail of that image is displayed on the post to avoid loading of large images. So please explain what exactly you're looking for?

 

Posts: 8
Customer
Topic starter
(@venkat-mangudi)
Member
Joined: 3 years ago

Use case: I need to allow the users to upload images in the forums. However, the images are being compressed and the quality as seen online is sub-par. How can I turn off the compression feature in the add-on?

1 Reply
 Tom
Admin
(@tomson)
Joined: 9 years ago

Famed Member
Posts: 4173

@venkat-mangudi,

put this code in the functions.php file of your current active theme:

add_filter('wpforoattach_uploader_class_options', function($options){
   $options['image_versions']['']['jpeg_quality'] = 100;
   $options['image_versions']['']['max_height'] = 1920;
   $options['image_versions']['thumbnail']['jpeg_quality'] = 100;
   return $options;
});
Posts: 8
Customer
Topic starter
(@venkat-mangudi)
Member
Joined: 3 years ago

Thank you, Tom. I am on a wordpress.com hosted site. Not super-technical on PHP though. Can you point to me where I can edit this file?

You assistance is much appreciated.

1 Reply
 Tom
Admin
(@tomson)
Joined: 9 years ago

Famed Member
Posts: 4173
Posts: 8
Customer
Topic starter
(@venkat-mangudi)
Member
Joined: 3 years ago

Thank you, Tom. That worked well. 

Share:
Scroll to top