Upload Directory Filtering Bug
-
When using the UberMenu I found a strange bug on the avatar crop page. It breaks image paths that are in the upload directory.
It’s is changing the img url from:
http://example.com/wp-content/uploads/2011/06/menu1.pngTo:
http://example.com/wp-content/uploads/avatars/9/2011/06/menu1.pngFrom the plugin developer:
http://codecanyon.net/item/ubermenu-wordpress-mega-menu-plugin/discussion/154703?page=18&filter=All%20Discussion#comment_1227533It’s unfortunate that that solution didn’t pan out, but we were pursuing it based on your suggestion, as I was unable to observe the issue myself at the outset. Now that I am back home with a computer I can investigate and diagnose the problem on my own machine. And I have discovered, in fact, this is not an UberMenu bug at all.
I installed WordPress 3.2, UberMenu 1.1.2, and BuddyPress 1.2.9, with the default BuddyPress theme. I set up an UberMenu with a thumbnail image.
Then I uploaded and cropped an avatar – everything worked perfectly with the upload and crop process.
The only issue was that, on that single screen, the thumbnail image in the menu did not show up, because the source URL was incorrect (as you originally reported). And as I said at the beginning, I had no idea why that would happen – it doesn’t make any sense that UberMenu would be changing this.
I have spent a lot of time tonight digging through the BuddyPress and WordPress core, looking for how the two plugins could be interacting. I’ve determined there is nothing wrong on UberMenu’s end. Rather, BuddyPress changes the WordPress uploads directory for its own purposes on the avatar crop page. As a result, when UberMenu calls the WordPress standard
wp_get_attachment_image_src
function, which callsimage_downsize
, which callswp_get_attachment_url
, which callswp_upload_dir
, the wrong upload directory (in this case, BuddyPress’s avatar directory) is returned. So UberMenu has been provided the incorrect path for the thumbnail from the core WordPress functions, because BuddyPress has changed them. The code is in this line:/*buddypress/bp-core/bp-core-avatars.php line 356 */
add_filter( 'upload_dir', $upload_dir_filter, 10, 0 );
The BuddyPress function that handles this filter is
xprofile_avatar_upload_dir
in bp-xprofile.php.As I see it, you have three options:
1. Live with the menu thumbnails going blank on that single page
2. Ask BuddyPress to change how their upload directory filtering works, as it is clearly affecting other plugins that rely on the built in WordPress functionality.
3. Write a “hack” that tests for these BuddyPress-generated avatar upload paths and strip them out before the images are printed via the UberMenu custom walker.
It seems that this is either an oversight on BuddyPress’ part, or this was the only way to accomplish their desired functionality without editing the core. Either way, the proper solution involves changes to BuddyPress, not UberMenu.:
- The topic ‘Upload Directory Filtering Bug’ is closed to new replies.