WordPress.org

Ready to get started?Download WordPress

Forums

EWWW Image Optimizer
Feature Request: Add Custom Directories (55 posts)

  1. Martin
    Member
    Posted 11 months ago #

    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.

    Thoughts?

    http://wordpress.org/plugins/ewww-image-optimizer/

  2. nosilver4u
    Member
    Plugin Author

    Posted 11 months ago #

    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.

  3. jcarrier
    Member
    Posted 10 months ago #

    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.

    http://www.webpagetest.org/result/130924_EW_P8E/
    http://www.worldnewsreader.com

    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.

    Thanks.

  4. nosilver4u
    Member
    Plugin Author

    Posted 10 months ago #

    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.

  5. jcarrier
    Member
    Posted 10 months ago #

    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.

  6. nosilver4u
    Member
    Plugin Author

    Posted 10 months ago #

    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.

  7. jcarrier
    Member
    Posted 10 months ago #

    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

  8. nosilver4u
    Member
    Plugin Author

    Posted 10 months ago #

    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).

  9. jcarrier
    Member
    Posted 10 months ago #

    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 300x138 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.

  10. jcarrier
    Member
    Posted 10 months ago #

    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.

  11. nosilver4u
    Member
    Plugin Author

    Posted 10 months ago #

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

    jcarrier,
    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.

  12. Martin
    Member
    Posted 10 months ago #

    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.

  13. jcarrier
    Member
    Posted 10 months ago #

    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.

  14. nosilver4u
    Member
    Plugin Author

    Posted 10 months ago #

    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.

  15. Martin
    Member
    Posted 10 months ago #

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

  16. jcarrier
    Member
    Posted 10 months ago #

    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.

    jcarrier

  17. nosilver4u
    Member
    Plugin Author

    Posted 10 months ago #

    Just FYI, when PHP says Warning, that is not the same as an 'error'. It may seem like splitting hairs, but in PHP a Warning is not fatal, the script will keep running. An actual Error in PHP is fatal and will usually kill the running script. I had noticed that in my logs and forgot to do anything with it, so I'll get that pushed out to the repository shortly.

  18. nosilver4u
    Member
    Plugin Author

    Posted 10 months ago #

    Ok, fixes are in dev, had to work through one more quirk since metaslider calls the optimization from the front-side of the website and not the admin.

    Probably causes a small performance hit, but only when it actually has to generate new images. Once they are generated, the plugin should be totally ignored since wp uses 'lazy-loading' for the wp_image_editor classes.

    Trying to work out how to allow optimizing previous metaslider (and other) images in the uploads/ folder without re-optimizing EVERYTHING in the uploads/ folder, which is generally going to be less than desirable.

    It might be feasible to query the database to generate a list of metaslider images instead. I'll post back if I figure anything out on that.

  19. Matcha Labs
    Member
    Posted 10 months ago #

    Hi nosilver4u,

    You're quite right, Meta Slider will create an image if it can't find a previously resized image when the slideshow is loaded. In the future I might change it so it creates those images when the slideshow is saved. It should check the file system before creating a new image, so if one exists it will never get as far as WP_Image_Editor.

    If there an action that I can call after Meta Slider has done its image resizing to invoke EWWW to do its thing?

    Regards,
    Tom.

  20. jcarrier
    Member
    Posted 10 months ago #

    Thanks so much for the join collaboration on this. You guys are awesome!

  21. nosilver4u
    Member
    Plugin Author

    Posted 10 months ago #

    ML, at this point I've integrated EWWW into the wp_image_editor class in the dev version of EWWW so that any image created with wp_image_editor will be automatically optimized. So, if you create the images when the slideshow is saved, you could still use wp_image_editor to process the image, which would automatically invoke the EWWW plugin when the images are created. In my opinion, that would be ideal from a performance standpoint, as the optimization can cause small delays in page load if a user does a slider with PNG images.

    The current issue is how to optimize previously created metaslider images. So I did some digging on that this morning, and I think I can query that from the database quite easily. The only thing I'm unsure of is if meta-slider pro stores things in the database differently than meta-slider lite. In particular, I'm curious if the meta key is still ml-slider_type in the postmeta table?

  22. nosilver4u
    Member
    Plugin Author

    Posted 10 months ago #

    I'm done working on this until Monday. The only thing left is to query for a list of metaslider images for the bulk 'Optimize More' process. wp_image_editor is fully implemented, among other things. Try out the dev release, beat the crap out of, and let me know if you find any other bugs (even warnings, I don't like to leave loose ends hanging).

  23. jcarrier
    Member
    Posted 10 months ago #

    @nosilver4u - I have the Meta Slider Pro version and I checked my DB this morning. The meta key is indeed ml-slider_type so perhaps that will help for coding on your end. The only other meta key reference for Meta Slider Pro in postmeta table is ml-slider_settings.

    @matchalabs - Perhaps you can confirm my finding on this. Thanks again.

  24. jcarrier
    Member
    Posted 10 months ago #

    @nosilver4u - Just so I understand the process at this point. Please confirm.

    - I should download the Development Version (svn) from the repository

    - The EWWW Image Optmizer plugin will now optimize images automatically based on images that are resized "on the fly" by the Meta Slider Pro plugin without any further settings required such as specifying directories in the EWWW Image Optimizer plugin settings menu.

    This automatic optimization for "on the fly" created images is important as my site needs to constantly create images for the slider based on the most recent 15 posts. Also, I want to verify that the EWWW Image Optimizer will not impede any rendering performance for my website.

    Please let me know if there is anything else that I need to do to make this work.

    Much appreciated...

    jcarrier

  25. nosilver4u
    Member
    Plugin Author

    Posted 10 months ago #

    1. correct, but make sure you click on Development Version, and not svn (unless you want to browse the repository)

    2. correct

    previously uploaded images will still need to be optimized, which is what I'll be working on today.

    Also, there will be a small performance hit when the image is first rendered, but it wasn't noticeable in my testing (unless you're using PNGs in your sliders), and it only happens once for each image. Once an image has been rendered the first time, meta-slider stores it on disk for future page loads, and it is never re-rendered (as far as I can tell).

    Additionally, it sounds like the meta-slider folks are looking at generating the images on the back-end in the future, which would mean absolutely NO performance hit on the front-end.

  26. jcarrier
    Member
    Posted 10 months ago #

    Awesome; thanks so much for your help with this. Please keep me updated on future developments, and I'll be happy to help you beta test/finalize. Much appreciated...

  27. jcarrier
    Member
    Posted 10 months ago #

    @nosilver4u - Here are the tangible results of your hard work on this.

    http://www.webpagetest.org/result/131014_HR_KN5/

    I can 't thank you enough for the 100% progressive jpegs score!

  28. jcarrier
    Member
    Posted 10 months ago #

    @nosilver4u - Ok; quick follow up question. Is the plugin also compressing the meta slider resized images? I don't see where that is the case and of course the resized images don't show up in my Admin Media Library. Please let me know.

  29. nosilver4u
    Member
    Plugin Author

    Posted 10 months ago #

    Yup, the resizes are the specific ones we are targeting with the new extensions to the WP_Image_Editor classes. You should be able to look under 'Optimize More' in the Tools menu and click the Show Table button to see a list of what has been optimized so far.

  30. jcarrier
    Member
    Posted 10 months ago #

    If the images are compressed and optimized, then shouldn't the compressed images section of the test also be 100%? Are the test results reflecting the true extent of the plugin to compress the images or are the images not being properly compressed?

    Perhaps I am missing something here?

    Here are the results that I am seeing based on the current four images:

    Compress Images: 98/100
    1,149.4 KB total in images, target size = 1,128.9 KB - potential savings = 20.5 KB

    FAILED - (20.2 KB, compressed = 12.8 KB - savings of 7.4 KB) - http://www.worldnewsreader.com/wp-content/uploads/image-1381764609-1861765140-300x138.jpg
    WARNING - (19.6 KB, compressed = 14.2 KB - savings of 5.4 KB) - http://www.worldnewsreader.com/wp-content/uploads/image-1381761017-1360418446-300x138.jpg
    WARNING - (14.2 KB, compressed = 10.1 KB - savings of 4.1 KB) - http://www.worldnewsreader.com/wp-content/uploads/image-1381757410-335297968-300x138.jpg
    WARNING - (12.3 KB, compressed = 8.7 KB - savings of 3.6 KB) - http://www.worldnewsreader.com/wp-content/uploads/image-1381765640-1162725296-300x138.jpg

Reply »

You must log in to post.

About this Plugin

About this Topic

Tags

No tags yet.