Title: Calling Function Manually
Last modified: August 20, 2016

---

# Calling Function Manually

 *  Resolved [Dewey Bushaw](https://wordpress.org/support/users/styledev/)
 * (@styledev)
 * [13 years, 3 months ago](https://wordpress.org/support/topic/calling-function-manually/)
 * I am using [https://github.com/matthewruddy/wordpress-timthumb-alternative/](https://github.com/matthewruddy/wordpress-timthumb-alternative/)
   and I wanted to know if there is an easy way to integrate the ewww optimization
   to work with this resize tool.
 * It uses the new “wp_image_editor” class and I did see your TODO noting integrating
   into this. Any idea when you could get around to this because it would bring 
   me to 100/100 pagespeed score!
 * Thanks and much appreciated!
 * [http://wordpress.org/extend/plugins/ewww-image-optimizer/](http://wordpress.org/extend/plugins/ewww-image-optimizer/)

Viewing 4 replies - 1 through 4 (of 4 total)

 *  Plugin Author [Shane Bishop](https://wordpress.org/support/users/nosilver4u/)
 * (@nosilver4u)
 * [13 years, 3 months ago](https://wordpress.org/support/topic/calling-function-manually/#post-3480186)
 * it’s going to be a while (if ever), since I’m in the middle of expanding support
   to Windows & FreeBSD, and I’ve not seen the documentation for creating a new 
   wp_image_editor class yet. At any rate, EWWW IO works with the existing Worpdress
   resize functions by running when the metadata is updated, so I’m curious to see
   why/if the one you are using skips that step. Generally, any resize operation(
   at least using the default WP method) creates a file with a new name, which requires
   calling the function to update metadata, which is where I’ve hooked into.
 * All that to say, it SHOULD already work. If it doesn’t, that is quite strange.
 *  Thread Starter [Dewey Bushaw](https://wordpress.org/support/users/styledev/)
 * (@styledev)
 * [13 years, 3 months ago](https://wordpress.org/support/topic/calling-function-manually/#post-3480187)
 * Interesting, can you point me to the best place to throw in an output to see 
   when it runs? Something like echo “I am running”; exit();?
 * Documentation: [http://codex.wordpress.org/Class_Reference/WP_Image_Editor](http://codex.wordpress.org/Class_Reference/WP_Image_Editor)
 * Maybe it is running, but PageSpeed is kicking the new images back saying they
   need to be optimized by about 4% each. You can see below that wp_update_attachment_metadata
   does get called.
 * …
 *     ```
       $editor->crop( $src_x, $src_y, $src_w, $src_h, $dest_width, $dest_height );
       $saved = $editor->save( $dest_file_name );
       // Add the resized dimensions to original image metadata (so we can delete our resized images when the original image is delete from the Media Library)
       $metadata = wp_get_attachment_metadata( $get_attachment[0]->ID );
       if ( isset( $metadata['image_meta'] ) ) {
       	$metadata['image_meta']['resized_images'][] = $resized_width .'x'. $resized_height;
       	wp_update_attachment_metadata( $get_attachment[0]->ID, $metadata );
       }
       ```
   
 * …
 *  Thread Starter [Dewey Bushaw](https://wordpress.org/support/users/styledev/)
 * (@styledev)
 * [13 years, 3 months ago](https://wordpress.org/support/topic/calling-function-manually/#post-3480188)
 * Here is a link to the core file that handles the ->save above:
 * [http://core.trac.wordpress.org/browser/trunk/wp-includes/class-wp-image-editor-imagick.php](http://core.trac.wordpress.org/browser/trunk/wp-includes/class-wp-image-editor-imagick.php)
 *  Plugin Author [Shane Bishop](https://wordpress.org/support/users/nosilver4u/)
 * (@nosilver4u)
 * [13 years, 3 months ago](https://wordpress.org/support/topic/calling-function-manually/#post-3480210)
 * You could put that somewhere around line 787 in ewww-image-optimizer.php
    The
   ewww_image_optimizer() function gets called anytime an optimize is called for(
   on a resize, upload, bulk action, etc.), and that would let you know if the hook
   is working.

Viewing 4 replies - 1 through 4 (of 4 total)

The topic ‘Calling Function Manually’ is closed to new replies.

 * ![](https://ps.w.org/ewww-image-optimizer/assets/icon-256x256.png?rev=1582276)
 * [EWWW Image Optimizer](https://wordpress.org/plugins/ewww-image-optimizer/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/ewww-image-optimizer/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/ewww-image-optimizer/)
 * [Active Topics](https://wordpress.org/support/plugin/ewww-image-optimizer/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/ewww-image-optimizer/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/ewww-image-optimizer/reviews/)

 * 4 replies
 * 2 participants
 * Last reply from: [Shane Bishop](https://wordpress.org/support/users/nosilver4u/)
 * Last activity: [13 years, 3 months ago](https://wordpress.org/support/topic/calling-function-manually/#post-3480210)
 * Status: resolved