
WordPress App Image Resize Failure While Upload
- June 26, 2015
- Leave a comment
WordPress has recently launched its revolutionary Mobile Application which just lets you connect with your wordpress.com or self-hosted WordPress site. You can administer your dashboard by using its Android or iOS App.
WordPress App takes care of mainly all core functions of WordPress. However, some filters added by a third party plugins may not work correctly. Image resize functionality while uploading is one example that does not work with this application.
wp_handle_upload does not find absolute path when filters are applied on request from WordPress App. It only contains names which causes the failure of image resize functionality when it is done through WordPress App. Adding the following code to your funcitons.php file will resolve this issue of resize while uploading:
1 2 3 4 5 6 7 8 9 |
add_action('wp_handle_upload', 'add_abspath_to_file'); function add_abspath_to_file($array) { $upload_dir = wp_upload_dir(); if(!strstr($array['file'], $upload_dir['path'])){ $array['file']=$upload_dir['path'].'/'.$array['file']; } return $array; } |
Apart from this solution, there is another fix that might be required in some cases that is ‘featured image’ attachment. If attached featured images are not being resized, use add_attachment hook to get the image path and then apply resize functionality from that plugin which you are using to resize images.
User Comments