The MU forums have moved to WordPress.org

ImageManager for WPMU (18 posts)

  1. quenting
    Member
    Posted 12 years ago #

    http://www.soderlind.no/archives/2006/01/03/imagemanager-20/

    This looks like an awesome plugin. However I couldn't get it to work on WPMU. Did anyone try/succeed ?

  2. donncha
    Key Master
    Posted 12 years ago #

    Looks very nice alright, but I can imagine the resizing and other image functions could be stressful on your server. No, I haven't tried it!

  3. cori
    Member
    Posted 12 years ago #

    I was able to get this running in MU with the following changes to the plugin. All changes below made to imagemanager-plugin.php within the ps_imagemanager_config function.

    * line 67 add $blog_id to the global list for function ps_imagemanager_config()
    * line 98 change to $IMConfig['base_dir'] = str_replace( "\\", "/",ABSPATH) . 'wp-content/blogs.dir/' .$blog_id . '/files/';
    * line 100 change to $IMConfig['base_url'] = str_replace( "\\", "/",$atmp['path']) . '/files/';
    * line 176 add "strpos($_SERVER['REQUEST_URI'],'post-new.php'"

    Line 67 makes the blog ID available to the config function.
    Line 98 sets the default path to the correct path for the current blog. This is then in place when a new blogger activates the plugin.
    Line 100 sets the default URL for the uploads to the URL for the "files" directory.
    Line 176 adds the URL for the new post page in MU to the list of pages that receive the ImageManager plugin's javascript.

    Obviously all of these are relative to the version of the plugin that I have running, which was the most recent on 2006-07-15. These changes also mean that by defaulkt all of the uploads from ImageMansger will go right inot the files directory, not into year/month sub-directories.

    I plan to make these changes in such a way to allow them to work with non-MU blogs as well and suggest the changes back to the author.

  4. andrewbillits
    Member
    Posted 12 years ago #

    I agree, it looks very nice. However, if you had 1,000 users and even 10% of those used the plugin on a daily basis you would have to have a beefy server.

    I wrote a photo gallery plugin for my personal blog last year and I noticed that every time a image function such as resize was called the server bogged down for a second. Imagine that x100.

  5. cori
    Member
    Posted 12 years ago #

    Luckily in my case the bloggers are unlikely to do any resizing or any kind of heavy-duty image handling but my client is unhappy with the built-in image manager, so this should fit the bill nicely.

  6. quenting
    Member
    Posted 12 years ago #

    thanks Cori! I'll look into your changes on my test env.
    Regarding resources, currently with 18000 blogs, my server's CPU is still doing quite good, however my disk space is going down *really* quickly.

  7. quenting
    Member
    Posted 12 years ago #

    excellent, it works :). Now the only thing is I don't want the options to be available to all users, but just the admin, who sets them for everyone. i have the same sort of issue with spam karma plugin. I guess I'll just go through the files and change things around for the config aspects.

  8. cori
    Member
    Posted 12 years ago #

    quenting; I'm curious if you have it running on RC4. I had it running on a march nightly but uograded to RC4 last night and it botching things up. Or at least I thinkit's the problem.

    I agree that isolating the config options to admin would be helpful, but I think that's something tht would be handy for many plugins. It would actually be nice if plugins placed in mu-plugins gave only admin config options.

  9. suleiman
    Member
    Posted 12 years ago #

    cori did you, or anyone else, ever get this problem solved? I'm very interested in using this as my blog users have complained about the image uploading interface.

  10. suleiman
    Member
    Posted 12 years ago #

    could someone let me know how to follow the instructions in the original post? (e.g., What would be the line changes required to add $blog_id to the global functions set?)

  11. cori
    Member
    Posted 12 years ago #

    hey suleiman;

    I was able to get it to work - it's working a charm right now except that we'd like to not have it insert dims on the images - in fact we want to disable resizing entirely and remove the height and width, but haven't gotten around to it yet.

    Here are the changes I've made in imagemanager-plugin.php:
    line 67 now reads:
    global $ps_imagemanager_root, $blog_id;

    line 99 now reads:
    $IMConfig['base_dir'] = str_replace( "\", "/",ABSPATH) . 'wp-content/blogs.dir/' .$blog_id . '/files/';

    line 101 now reads:
    $IMConfig['base_url'] = str_replace( "\", "/",$atmp['path']) . '/files/' ;

    line 177 now reads:
    if (is_array(get_settings('ps_imagemanager_options')) && (strpos($_SERVER['REQUEST_URI'], 'post.php') || strpos($_SERVER['REQUEST_URI'],'page-new.php') || strpos($_SERVER['REQUEST_URI'],'post-new.php'))) {

    The purposes of those changes are the same but the linenumbers are slightly offset from my original post and are correct in my install, which is version 2.3.7

    I never did make the updates to suggest back to Per Soderlind that I referenced above; it dropped off my radar before I could spare the time for it.

  12. suleiman
    Member
    Posted 12 years ago #

    cori, when I make the modifications you suggested my page doesn't load. Would it be possible for you to save your image-manager.php file as a phps file or make it available for download in an archive? Since there are no domain-specific commands in the file that would be the easiest way to test it out.

    Thanks!

    EDIT: I did download the new package, and after making a few modifications to the text you posted (adding a \ where I thought there should 2 instead of 1) I can now get the plugin to activate and load correctly.

    The problem is that my TinyMCE editor doesn't show the image manager button at all. I don't know if this is a problem with buttonsnap or what. But could you please detail if this is in your mu-plugins folder or your plugins folder, and what if any extra steps you took to get this to work on your blogs?

    Thanks again ;)

  13. cori
    Member
    Posted 12 years ago #

    suleiman;

    where did you add the "\"? I copied/pasted exactly what's in my file, but perhaps I neglected a character...

    do/did you have the advimage plugin for TinyMCE enabled before? I didn't make any imagemanager-specific changes to TinyMCE for the IM button to appear, but I have a plugin adding a few buttons to TMCE (take a look at http://wpmu.pastebin.ca/172975). Perhaps something having to do with that made it work for us. I diffed the orignal ImageManager I downloaded and the contents of out current install and the only diffs are those I presented above.

  14. suleiman
    Member
    Posted 12 years ago #

    cori, that doesn't make sense. In the imagemanager.php file my line 67 is the same, 99 reads:

    $IMConfig['base_dir'] = str_replace( "\\", "/",ABSPATH) . 'wp-content/blogs.dir/' .$blog_id . '/files/';

    My line 101 reads:

    $IMConfig['base_url'] = str_replace( "\\", "/",$atmp['path']) . '/files/' ;

    The area where I added the extra "\" is in the first quotes following the str_replace command on both lines, where in the post above it seemed you only had one "\". In my php file, if I put only one "\" there, then it fails to parse properly, and in dreamweaver I can actually see that dreamweaver fails to interpret any lines following line 99 if I don't add the exra "\".

    177 is also the same as your post.

    I added the plugin you mentioned and activated it to see the buttons for that plugin do appear, but still no imagemanager buttons. :(

    If you could post your own imagemanager-plugin.php file somewhere as a phps file that would be great for me to run my own tests on.

    Thanks again!

  15. cori
    Member
    Posted 12 years ago #

    Ah. That'll teach me for not actually checking the code :(

    I said I copied and pasted the code, which is true, but I assumed that meant that what I pasted was what displayed without checking. That makes me an ass.

    I expect that bbPress treated my double-slash as an escape sequence, because I do indeed have 2 slashes while my post has only one. Sorry for the confusion.

    Here's my file: http://kinrowan.net/development/imagemanager-plugin.phps

  16. suleiman
    Member
    Posted 12 years ago #

    thanks for posting your file cori!

    Now if only I could figure out why the button isn't showing up. Are you sure you didn't modify anything in the rest of your TinyMCE setup? If not, then what build of WPMU are u using? And could you give me the link to the test blog on your site so I could see it in action?

    One thing I found very odd, f I point my browser directly to the image manager plugin (http://home.hadithuna.com/wp-content/plugins/ImageManager/manager.php) then I get an invalid base directory error. Is this something that goes away when it's loaded from within TinyMCE? Or is this what's keeping it from loading in TinyMCE in the first place?

  17. cori
    Member
    Posted 12 years ago #

    nprb.

    I did some digging, and some diffing, just to confirm what my memory remembers....

    I'm running WPMU RC4, upgraded from a nightly from last May, I think it was. Something like r539. My TinyMCE directory has no diffs between the TinyMCE that came with RC4 and what's on my server except for a few files that are only in the OOTB version that I'm not using in our server's version. You can see the diff at http://wpmu.pastebin.ca/173949. So that confirms that OI made no changes to the core delivered tinymce config files.

    I also diffed a freshly downloaded 2.3.7 version of ImageManager against my server's version; the only diffs were the 4 lines we discussed above, so nothing new there.

    You've got my TinyMCE hook plugin, so nothing there either.

    I see you've been on one of the threads discussing TinyMCE and buttonsnap problems, so I suspect you've done the hard refresh to get around your browser's cache.

    When I browse to the plugin location, I get a window of the plugin, so there's obviously something wrong there. It's possible, I suppose, that ImageManager is bailing out on an error before it gets to the buttonsnap insertion code. Obviously since I can't login to your site I can't see the error on the plugin; can you post a link to a screenshot of your ImageManager options screen? What's the base directory ImageManager's trying to use for the home.xx blog, and does it actually exist? Keep in mind that in MU RC4, the "files" directory is no longer created on blog creation, but only when the first file is uploaded (a fact I neglected to point out earlier - I create that file on the wpmu_new_blog() hook with a plugin - I think I'll file a ticket for that). Perhaps creating the files directory will get you closer, though when I purposefully point to a bad directory I still get the button, but get an error in the ImageManager window.

    Contact me off-forum and I'll get you a temp login to my MU site. You can find me at http://kinrowan.net/contact.

  18. cori
    Member
    Posted 12 years ago #

    Turns out the issue was that ImageManager doesn't activate until the user has saved the options page, even with defaults turned on (checks for values in the options table before showing the button, and doesn't insert those values until the options page is saved).

About this Topic