Uploads bypass Imsanity plugin
-
Client’s website allows members to upload photos, but the uploaded images bypass the Imsanity plugin that resizes large uploads. Is there an image resize plugin that works with the WP File UPload plugin to resize uploads?
The page I need help with: [log in to see the link]
-
Hi, open the visual editor of the plugin, go to Interoperability tab and activate option “Include Uploaded Files in Media”. This will make the uploaded files be added in Media Library of your website and maybe they will be resized by Imsanity plugin.
Try it and let me know.
Regards
Nickolas
Nickolas-
The “Include Uploaded Files in Media” is checked (and the images get added to the Media Library just fine), but I’ve tried three different “image resize” plugins and all of them fail to resize images that are uploaded using the WordPress File Upload plugin. Of course, the images can be resized manually after upload, but with the number of members my client has, and each member will be uploading multiple images, we are hoping to find a way to handle the resizing automatically. I also have reduced the maximum file size to 1MB. I’m just surprised that the file upload bypasses the resize plugins.
Jennifer
Hi. I have very limited online access these days and I delay responding.
It seems that these resize plugins are hooked to the default upload form of WordPress Media Library.
Can you tell me their names? Maybe I can figure out a way to integrate with one of them.
Nickolas
Nickolas-
The image-upload-resizer plugin I use the most is Imsanity. I also tried EWWW Image Optimizer by Exactly WWW and Smush by WPMU DEV.
Jennifer
Hi, try this hook. You need to put it in functions.php file of your theme:
if (!function_exists('wfu_after_upload_ims')) { function wfu_after_upload_ims($changable_data, $additional_data) { foreach ( $additional_data["files"] as $file ) { if ( $file["upload_result"] == "success" || $file["upload_result"] == "warning" ) { $params["file"] = wfu_basename($file["filepath"]); $params["url"] = str_replace(ABSPATH, site_url().'/', $file["filepath"]); $params["type"] = wfu_mime_content_type($file["filepath"]); if ( function_exists("imsanity_handle_upload") ) imsanity_handle_upload( $params ); } } return $changable_data; } add_filter('wfu_after_upload', 'wfu_after_upload_ims', 10, 2); }It should work with imsanity. I haven’t tested it though, so let me know if it works.
Nickolas
Nickolas-
It didn’t work, but thank you for trying.
Jennifer
Ok I managed to make it work. Here is the correct hook:
if (!function_exists('wfu_after_upload_ims')) { function wfu_after_upload_ims($changable_data, $additional_data) { foreach ( $additional_data["files"] as $file ) { if ( $file["upload_result"] == "success" || $file["upload_result"] == "warning" ) { $params["file"] = $file["filepath"]; $params["url"] = str_replace(ABSPATH, site_url().'/', $file["filepath"]); $params["type"] = wfu_mime_content_type($file["filepath"]); if ( function_exists("imsanity_handle_upload") ) imsanity_handle_upload( $params ); wfu_process_media_insert($file["filepath"], $file["user_data"], 0); } } return $changable_data; } add_filter('wfu_after_upload', 'wfu_after_upload_ims', 10, 2); }Please note that you need to deactivate “Add Uploaded Files in Media” in the shortcode. The hook will make sure by its own that files are added in Media.
Regards
Nickolas
Nickolas –
Yes!! This works. Thank you so much.
Jennifer
ok nice
The topic ‘Uploads bypass Imsanity plugin’ is closed to new replies.