Support » Plugin: EWWW Image Optimizer » Feature Request: Add Custom Directories

  • While finetuning my new VPS, I’ve been looking into Google Pagespeed.

    The takeaway from that is there’s certain plugin directories like my Banner Ads as well as Custom Optin Form Generator that contain unoptimised images.

    It would be helpful to be able to optimise these as well with EWWW and even add them to a list of special media directories such as what was done with BuddyPress.


Viewing 15 replies - 1 through 15 (of 54 total)
  • Plugin Author nosilver4u


    Ensuring the proper permissions for additional folders could get tricky. If those folders are referenced by particular plugins, it would be easier to pull a list of images that the plugin knows about. However, I’m thinking there might be a way to restrict the function to blog admins, and only allow folder within the WP install. I’ll have to give that some more thought.

    I have an issue related to a slider (MetaSlider Pro) that resizes images and saves them to the uploads directory but not the Media Library. As a result, the jpegs for the slider are not progressive jpegs.

    The EWWW Image Optimizer only appears to optimize images that are included in the Media Library. Please let me know if I am missing something.

    I am conversant with LAMP installations and pretty good with rewriting PHP code so perhaps there is a way that I can specify that all images (i.e. jpegs) within the uploads directory be optimized. That way, the EWWW image optimizer plugin would optimize the images automatically.

    Please advise on how to best resolve this issue.


    Plugin Author nosilver4u


    In the file aux-optimize.php, look for the place where it gets (and sets) the path for theme images. You can then hardcode that temporarily to allow you to optimize any folder on your install.

    Thanks for the reply. The folder I want to optimize all images is wp-content/uploads. Can you be more specific as to how to code that into the aux-optimize.php file?

    Thanks again.

    Plugin Author nosilver4u


    It doesn’t put them in a sub-folder at all? That could be problematic, since the ‘aux-optimizer’ file does a recursive search.

    The place you are looking for looks like this:

    // collect a list of images if we are working with a theme
            if ($theme_images) {
                    $child_path = get_stylesheet_directory();
                    $parent_path = get_template_directory();
                    $attachments = ewww_image_optimizer_image_scan($child_path);
                    if ($child_path !== $parent_path) {
                            $attachments = array_merge($attachments, ewww_image_optimizer_image_scan($parent_path));

    the ones you want to change are $child_path & $parent_path. Set them to the absolute path of the folder you want to optimize, then use the Theme optimizer to see how many images it finds and start optimizing…

    If you need to use the theme optimizer in the future, just revert it back to the original values.

    Where is it coded to only optimize images that are contained within the Media Library? I wish to change that subset of images to optimize all images in the uploads directory.

    Also, are the images automatically optimized within the Media Library or are there additional settings required to make that work for the plugin. It doesn’t seem to auto optimize images within the Media Library. When I view the Media Library it states “Not Optimized” next to images in the Media Library even after plugin installation.

    Here is my setup for the plugin, and I am running PHP 5.3 on a Linux Server on a shared Hostgator server. I haven’t changed or checked any of the plugin settings.

    Plugin Status

    If updated versions are available below, you may need to enable write permission on the wp-content/ewww folder to use the automatic installs.
    *Updates are optional, but may contain increased optimization or security patches

    jpegtran: OK version: Independent JPEG Group’s JPEGTRAN, version 9 13-Jan-2013
    optipng: OK version: OptiPNG version 0.7.4
    gifsicle: OK version: LCDF Gifsicle 1.70
    Graphics libraries – only need one, used for conversion, not optimization: GD: OK   Imagemagick ‘convert’: OK
    safe mode: Off  exec(): OK  
    Only need one of these: finfo: OK  getimagesize(): OK  mime_content_type(): OK

    Plugin Author nosilver4u


    The plugin gets the Media Library information from the database. It never looks at the filesystem until it is actually ready to optimize an image, so there isn’t really a way to just grab random folders of images in the core functions. So the aux-optimize.php file is your best bet for optimizing an entire folder full of images, but like I said, if those images aren’t in a sub-folder, that would get tricky (and shame on the plugin author for cluttering up the /uploads/ folder without creating a sub-directory).

    There is a Bulk Optimize utility under Media Library that let’s you optimize all previous images. All NEW images are auto-optimized on upload, but obviously this doesn’t include the MetaSlider images, nor could it, since the plugin has no way to ‘hook’ into the metaslider process (yet). If the plugin does have hooks, it is a definite possibility that I could add this functionality. Without hooks, all we can do is run the bulk optimizer routines periodically (or the Theme Optimizer in this case).

    The MetaSlider Pro team provided the following information. Perhaps it could be utilized within the EWWW plugin.

    The EWWW plugin seems to suggest it is integrated with the WP_Image_Editor. Could you try installing it and then uploading a new image to Meta Slider (while it is installed)? It should pick up any new images that are created by Meta Slider.

    Meta Slider creates images ‘on the fly’ and it doesn’t register those sizes with WordPress (if it did, then you could end up with hundreds of image sizes, and WordPress would be creating thumbnails for each size every time you uploaded a new media file). However, if you’re sticking with an image size of 300×138 for your slideshow, you should be able to get EWWW to optimize your images by adding this line to your functions.php file:

    add_image_size( ‘metaslider-homepage-thumb’, 300, 138, true );

    Therefore, I tried to add it tot the functions.php file but it doesn’t seem to work.

    Please advise. Thanks again.

    Here is additional information that may help to resolve this issue.

    I have a curating plugin that posts content periodically to my website. This saves jpeg images for each post to the main uploads directory. The MetaSlider Pro plugin creates resized images “on the fly” based on these images in the same main uploads directory.

    I need the EWWW Image Optimizer to auto optimize both the originally posted jpegs (which are added to the Media Library upon post creation) and the slider resized jpegs (which are NOT added to the Media Library but created in the main uploads directory).

    Please let me know how best to handle. Thanks again.

    Plugin Author nosilver4u


    Martin, some of this might apply to you to, if those plugins use the WP_Image_Editor stuff built into WP…

    I think the images that are automatically posted to your site should be optimized automatically, although someone recently had a plugin that was similar that was having issues with that.

    However, the MetaSlider stuff is going to be a different animal altogether. One thing I had looked at when they released WP 3.5 was the new WP_Image_Editor class. But I never went down that road, because I just didn’t see the need for it at the time.

    If I implement the WP_Image_Editor class, this might be able to handle all sorts of edge cases (like MetaSlider). Instead of just hooking into the Media Library, it essentially allows me to replace/enhance the built in WP image functions. Soooo, anything that uses those, which most plugins probably do, will automatically be getting their images optimized.

    Unfortunately, that’s a rather large undertaking, and it will take a while (this isn’t my day job after all). But I definitely want to put it on the roadmap for the future.

    Cool roadmap feature.
    I know the Banner Ads plugin is a direct image upload that is outside the WP Image stuff however the Optin Form one does use the builtin WP Image stuff.
    For the moment, I’ll end up downloading, optimising and uploading again so all is good.

    Thanks for the reply. I’d be more than happy to beta test whatever enhancements you develop in this regard. Please let me know, in the interim, if you have any further insights on how to resolve this issue.

    Plugin Author nosilver4u


    Ok, the ability to optimize user-specified folders within your wordpress install is now in the ‘dev’ version.
    There is also an option to enable the plugin to scan these folders on an hourly basis for new images to optimize (along with your active theme, buddypress, and symposium folders).

    UPDATE: should also add that (ideally) users should report folders created by plugins for automatic inclusion within the EWWW Image Optimizer plugin in future releases.

    OMG now that is dang cool!
    Need to check this out and a huge thank you too

    Shane –

    Thanks for the plugin update.

    It would be great if I could optimize images directly in the root uploads folder. Please let me know how I can accomplish that.

    Also, I received the following error after activating the plugin so please advise.

    Warning: array_shift() expects parameter 1 to be array, string given in /home2/wpadmin/public_html/wp-content/plugins/ewww-image-optimizer/aux-optimize.php on line 312

    Thanks again for your help.


Viewing 15 replies - 1 through 15 (of 54 total)
  • The topic ‘Feature Request: Add Custom Directories’ is closed to new replies.