AI Assistant
Notifications
Clear all

[Solved] Keep origina image sizes

7 Posts
2 Users
1 Reactions
1,802 Views
Posts: 8
Customer
Topic starter
Translate
English
Spanish
French
German
Italian
Portuguese
Russian
Chinese
Japanese
Korean
Arabic
Hindi
Dutch
Polish
Turkish
Vietnamese
Thai
Swedish
Danish
Finnish
Norwegian
Czech
Hungarian
Romanian
Greek
Hebrew
Indonesian
Malay
Ukrainian
Bulgarian
Croatian
Slovak
Slovenian
Serbian
Lithuanian
Latvian
Estonian
(@venkat-mangudi)
Member
Joined: 5 years ago
[#7639]

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: 4245
 Tom
Admin
Translate
English
Spanish
French
German
Italian
Portuguese
Russian
Chinese
Japanese
Korean
Arabic
Hindi
Dutch
Polish
Turkish
Vietnamese
Thai
Swedish
Danish
Finnish
Norwegian
Czech
Hungarian
Romanian
Greek
Hebrew
Indonesian
Malay
Ukrainian
Bulgarian
Croatian
Slovak
Slovenian
Serbian
Lithuanian
Latvian
Estonian
(@tomson)
Famed Member
Joined: 11 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
Translate
English
Spanish
French
German
Italian
Portuguese
Russian
Chinese
Japanese
Korean
Arabic
Hindi
Dutch
Polish
Turkish
Vietnamese
Thai
Swedish
Danish
Finnish
Norwegian
Czech
Hungarian
Romanian
Greek
Hebrew
Indonesian
Malay
Ukrainian
Bulgarian
Croatian
Slovak
Slovenian
Serbian
Lithuanian
Latvian
Estonian
(@venkat-mangudi)
Member
Joined: 5 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: 11 years ago

Famed Member
Posts: 4245
Translate
English
Spanish
French
German
Italian
Portuguese
Russian
Chinese
Japanese
Korean
Arabic
Hindi
Dutch
Polish
Turkish
Vietnamese
Thai
Swedish
Danish
Finnish
Norwegian
Czech
Hungarian
Romanian
Greek
Hebrew
Indonesian
Malay
Ukrainian
Bulgarian
Croatian
Slovak
Slovenian
Serbian
Lithuanian
Latvian
Estonian

@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
Translate
English
Spanish
French
German
Italian
Portuguese
Russian
Chinese
Japanese
Korean
Arabic
Hindi
Dutch
Polish
Turkish
Vietnamese
Thai
Swedish
Danish
Finnish
Norwegian
Czech
Hungarian
Romanian
Greek
Hebrew
Indonesian
Malay
Ukrainian
Bulgarian
Croatian
Slovak
Slovenian
Serbian
Lithuanian
Latvian
Estonian
(@venkat-mangudi)
Member
Joined: 5 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: 11 years ago

Famed Member
Posts: 4245
Translate
English
Spanish
French
German
Italian
Portuguese
Russian
Chinese
Japanese
Korean
Arabic
Hindi
Dutch
Polish
Turkish
Vietnamese
Thai
Swedish
Danish
Finnish
Norwegian
Czech
Hungarian
Romanian
Greek
Hebrew
Indonesian
Malay
Ukrainian
Bulgarian
Croatian
Slovak
Slovenian
Serbian
Lithuanian
Latvian
Estonian

@venkat-mangudi,

You can use certain plugin to add such codes. Here is a good article : https://www.wpbeginner.com/plugins/how-to-easily-add-custom-code-in-wordpress-without-breaking-your-site/


Posts: 8
Customer
Topic starter
Translate
English
Spanish
French
German
Italian
Portuguese
Russian
Chinese
Japanese
Korean
Arabic
Hindi
Dutch
Polish
Turkish
Vietnamese
Thai
Swedish
Danish
Finnish
Norwegian
Czech
Hungarian
Romanian
Greek
Hebrew
Indonesian
Malay
Ukrainian
Bulgarian
Croatian
Slovak
Slovenian
Serbian
Lithuanian
Latvian
Estonian
(@venkat-mangudi)
Member
Joined: 5 years ago

Thank you, Tom. That worked well. 


Share:
Scroll to top