Digital experiences for all disciplines
New Landing › How can we help? › Cardinal › Excessive Reoptimisation / Resizing of Images
New Landing › How can we help? › Cardinal › Excessive Reoptimisation / Resizing of Images
- This topic has 10 replies, 4 voices, and was last updated 8 years by David Martin – Support.
-
Posted in: Cardinal
-
November 3, 2016 at 4:47 am #300139
Hi,
We’ve been having a fairly large server load on our site and I believe it’s coming from the constant re-optimisation/re-sizing of images.
I’m currently using the EWWWW image optimiser and received the following error:
The EWWW Image Optimizer has detected excessive re-optimization of multiple images. Please turn on the Debugging setting, wait for approximately 12 hours, and then visit the Dynamic Image Debuggingpage. Reset Counters
After speaking with the EWWWW plugin support they mentioned there might be a bug in the aq_resizer function to size images. I’m wondering if you’re able to update the existing resizing code to properly check for existing images prior to creating a new resize version?
I’ve included the function for you below and below that some logs from the debugger
<?php
function get_pixelratio() {
if ( isset( $_COOKIE[“pixel_ratio”] ) ) {
$pixel_ratio = $_COOKIE[“pixel_ratio”];
if ( $pixel_ratio >= 2 ) {
// echo “Is HiRes Device”;/**
* Include AQ Resizer
*/
require( get_template_directory() . ‘/includes/plugins/aq_resizer-2x.php’ );} else {
//echo “Is NormalRes Device”;/**
* Include AQ Resizer
*/
require( get_template_directory() . ‘/includes/plugins/aq_resizer-1x.php’ );
}
} else {
require( get_template_directory() . ‘/includes/plugins/aq_resizer-1x.php’ );
?>
<script>
writeCookie();
function writeCookie() {
the_cookie = document.cookie;
if ( the_cookie ) {
if ( window.devicePixelRatio >= 2 ) {
the_cookie = “pixel_ratio=” + window.devicePixelRatio + “;” + the_cookie;
document.cookie = the_cookie;
//location = ‘<?php $_SERVER[‘PHP_SELF’] ?>’;
}
}
}
</script>
<?php
}//isset($_COOKIE[“pixel_ratio”])
}//get_pixelratio
add_action( ‘wp_enqueue_scripts’, ‘get_pixelratio’ );
?>LOGS::
File path: /var/www/vhosts/manofmany.com/httpdocs/wp-content/uploads/2015/11/mon_544430_black_project_pr_m08_dahinter1.jpg-720×540.jpg
Number of attempted optimizations: 205
Last attempted: 2016-10-30 21:18:13
PHP trace:
#0 ewww_image_optimizer() called at /var/www/vhosts/manofmany.com/httpdocs/wp-content/plugins/ewww-image-optimizer-cloud/image-editor.php:170
#1 _save() called at /var/www/vhosts/manofmany.com/httpdocs/wp-includes/class-wp-image-editor-gd.php:376
#2 save() called at /var/www/vhosts/manofmany.com/httpdocs/wp-content/themes/cardinal/includes/plugins/aq_resizer-1x.php:161
#3 sf_aq_resize() called at /var/www/vhosts/manofmany.com/httpdocs/wp-content/themes/cardinal/swift-framework/content/sf-post-formats.php:1371
#4 sf_get_recent_post_item() called at /var/www/vhosts/manofmany.com/httpdocs/wp-content/themes/cardinal/swift-framework/content/sf-post-detail.php:639
#5 sf_post_related_articles() called
#6 call_user_func_array() called at /var/www/vhosts/manofmany.com/httpdocs/wp-includes/plugin.php:524
#7 do_action() called at /var/www/vhosts/manofmany.com/httpdocs/wp-content/themes/cardinal-child/swift-framework/layout/single-post.php:328
#8 require() called at /var/www/vhosts/manofmany.com/httpdocs/wp-includes/template.php:574
#9 load_template() called at /var/www/vhosts/manofmany.com/httpdocs/wp-includes/template.php:531
#10 locate_template() called at /var/www/vhosts/manofmany.com/httpdocs/wp-includes/general-template.php:167
#11 get_template_part() called at /var/www/vhosts/manofmany.com/httpdocs/wp-content/themes/cardinal/swift-framework/core/sf-get-template.php:21
#12 sf_get_template() called at /var/www/vhosts/manofmany.com/httpdocs/wp-content/themes/cardinal/swift-framework/core/sf-base.php:111
#13 sf_base_layout() called at /var/www/vhosts/manofmany.com/httpdocs/wp-content/themes/cardinal-child/single.php:26
#14 include() called at /var/www/vhosts/manofmany.com/httpdocs/wp-includes/template-loader.php:75
#15 require_once() called at /var/www/vhosts/manofmany.com/httpdocs/wp-blog-header.php:19
#16 require() called at /var/www/vhosts/manofmany.com/httpdocs/index.php:17File path: /var/www/vhosts/manofmany.com/httpdocs/wp-content/uploads/2015/07/x68306_inuse2_2015_web_2.jpg.pagespeed.ic_.KGDfLi8cEv-320×222.jpg
Number of attempted optimizations: 22
Last attempted: 2016-10-30 21:03:34
PHP trace:
#0 ewww_image_optimizer() called at /var/www/vhosts/manofmany.com/httpdocs/wp-content/plugins/ewww-image-optimizer-cloud/image-editor.php:170
#1 _save() called at /var/www/vhosts/manofmany.com/httpdocs/wp-includes/class-wp-image-editor-gd.php:376
#2 save() called at /var/www/vhosts/manofmany.com/httpdocs/wp-content/themes/cardinal/includes/plugins/aq_resizer-1x.php:161
#3 sf_aq_resize() called at /var/www/vhosts/manofmany.com/httpdocs/wp-content/themes/cardinal-child/functions.php:566
#4 sf_post_thumbnail() called at /var/www/vhosts/manofmany.com/httpdocs/wp-content/themes/cardinal-child/functions.php:656
#5 sf_get_post_item() called at /var/www/vhosts/manofmany.com/httpdocs/wp-content/themes/cardinal/swift-framework/layout/archive.php:59
#6 require() called at /var/www/vhosts/manofmany.com/httpdocs/wp-includes/template.php:574
#7 load_template() called at /var/www/vhosts/manofmany.com/httpdocs/wp-includes/template.php:531
#8 locate_template() called at /var/www/vhosts/manofmany.com/httpdocs/wp-includes/general-template.php:167
#9 get_template_part() called at /var/www/vhosts/manofmany.com/httpdocs/wp-content/themes/cardinal/swift-framework/core/sf-get-template.php:21
#10 sf_get_template() called at /var/www/vhosts/manofmany.com/httpdocs/wp-content/themes/cardinal/swift-framework/core/sf-base.php:111
#11 sf_base_layout() called at /var/www/vhosts/manofmany.com/httpdocs/wp-content/themes/cardinal/archive.php:20
#12 include() called at /var/www/vhosts/manofmany.com/httpdocs/wp-includes/template-loader.php:75
#13 require_once() called at /var/www/vhosts/manofmany.com/httpdocs/wp-blog-header.php:19
#14 require() called at /var/www/vhosts/manofmany.com/httpdocs/index.php:17File path: /var/www/vhosts/manofmany.com/httpdocs/wp-content/uploads/2015/11/mon_544430_black_project_pr_m08_dahinter1.jpg-320×196.jpg
Number of attempted optimizations: 19
Last attempted: 2016-10-30 20:43:32
PHP trace:
#0 ewww_image_optimizer() called at /var/www/vhosts/manofmany.com/httpdocs/wp-content/plugins/ewww-image-optimizer-cloud/image-editor.php:170
#1 _save() called at /var/www/vhosts/manofmany.com/httpdocs/wp-includes/class-wp-image-editor-gd.php:376
#2 save() called at /var/www/vhosts/manofmany.com/httpdocs/wp-content/themes/cardinal/includes/plugins/aq_resizer-1x.php:161
#3 sf_aq_resize() called at /var/www/vhosts/manofmany.com/httpdocs/wp-content/themes/cardinal-child/functions.php:566
#4 sf_post_thumbnail() called at /var/www/vhosts/manofmany.com/httpdocs/wp-content/themes/cardinal-child/functions.php:656
#5 sf_get_post_item() called at /var/www/vhosts/manofmany.com/httpdocs/wp-content/themes/cardinal/swift-framework/layout/archive.php:59
#6 require() called at /var/www/vhosts/manofmany.com/httpdocs/wp-includes/template.php:574
#7 load_template() called at /var/www/vhosts/manofmany.com/httpdocs/wp-includes/template.php:531
#8 locate_template() called at /var/www/vhosts/manofmany.com/httpdocs/wp-includes/general-template.php:167
#9 get_template_part() called at /var/www/vhosts/manofmany.com/httpdocs/wp-content/themes/cardinal/swift-framework/core/sf-get-template.php:21
#10 sf_get_template() called at /var/www/vhosts/manofmany.com/httpdocs/wp-content/themes/cardinal/swift-framework/core/sf-base.php:111
#11 sf_base_layout() called at /var/www/vhosts/manofmany.com/httpdocs/wp-content/themes/cardinal/archive.php:20
#12 include() called at /var/www/vhosts/manofmany.com/httpdocs/wp-includes/template-loader.php:75
#13 require_once() called at /var/www/vhosts/manofmany.com/httpdocs/wp-blog-header.php:19
#14 require() called at /var/www/vhosts/manofmany.com/httpdocs/index.php:17File path: /var/www/vhosts/manofmany.com/httpdocs/wp-content/uploads/2016/10/KOBI_POV_06-600×400.jpg
Number of attempted optimizations: 2
Last attempted: 2016-10-30 19:03:56
PHP trace:
#0 ewww_image_optimizer() called at /var/www/vhosts/manofmany.com/httpdocs/wp-content/plugins/ewww-image-optimizer-cloud/background.php:249
#1 handle() called at /var/www/vhosts/manofmany.com/httpdocs/wp-content/plugins/ewww-image-optimizer-cloud/classes/wp-async-request.php:146
#2 maybe_handle() called
#3 call_user_func_array() called at /var/www/vhosts/manofmany.com/httpdocs/wp-includes/plugin.php:524
#4 do_action() called at /var/www/vhosts/manofmany.com/httpdocs/wp-admin/admin-ajax.php:91File path: /var/www/vhosts/manofmany.com/httpdocs/wp-content/uploads/2015/11/mon_544430_black_project_pr_m08_dahinter1.jpg-1170×717.jpg
Number of attempted optimizations: 14
Last attempted: 2016-10-30 18:33:06
PHP trace:
#0 ewww_image_optimizer() called at /var/www/vhosts/manofmany.com/httpdocs/wp-content/plugins/ewww-image-optimizer-cloud/image-editor.php:170
#1 _save() called at /var/www/vhosts/manofmany.com/httpdocs/wp-includes/class-wp-image-editor-gd.php:376
#2 save() called at /var/www/vhosts/manofmany.com/httpdocs/wp-content/themes/cardinal/includes/plugins/aq_resizer-1x.php:161
#3 sf_aq_resize() called at /var/www/vhosts/manofmany.com/httpdocs/wp-content/themes/cardinal/swift-framework/content/sf-post-formats.php:101
#4 sf_image_post() called at /var/www/vhosts/manofmany.com/httpdocs/wp-content/themes/cardinal/swift-framework/layout/detail-media.php:83
#5 require() called at /var/www/vhosts/manofmany.com/httpdocs/wp-includes/template.php:574
#6 load_template() called at /var/www/vhosts/manofmany.com/httpdocs/wp-includes/template.php:531
#7 locate_template() called at /var/www/vhosts/manofmany.com/httpdocs/wp-includes/general-template.php:167
#8 get_template_part() called at /var/www/vhosts/manofmany.com/httpdocs/wp-content/themes/cardinal/swift-framework/core/sf-get-template.php:21
#9 sf_get_template() called at /var/www/vhosts/manofmany.com/httpdocs/wp-content/themes/cardinal/swift-framework/content/sf-post-detail.php:150
#10 sf_post_detail_media() called
#11 call_user_func_array() called at /var/www/vhosts/manofmany.com/httpdocs/wp-includes/plugin.php:524
#12 do_action() called at /var/www/vhosts/manofmany.com/httpdocs/wp-content/themes/cardinal-child/swift-framework/layout/single-post.php:271
#13 require() called at /var/www/vhosts/manofmany.com/httpdocs/wp-includes/template.php:574
#14 load_template() called at /var/www/vhosts/manofmany.com/httpdocs/wp-includes/template.php:531
#15 locate_template() called at /var/www/vhosts/manofmany.com/httpdocs/wp-includes/general-template.php:167
#16 get_template_part() called at /var/www/vhosts/manofmany.com/httpdocs/wp-content/themes/cardinal/swift-framework/core/sf-get-template.php:21
#17 sf_get_template() called at /var/www/vhosts/manofmany.com/httpdocs/wp-content/themes/cardinal/swift-framework/core/sf-base.php:111
#18 sf_base_layout() called at /var/www/vhosts/manofmany.com/httpdocs/wp-content/themes/cardinal-child/single.php:26
#19 include() called at /var/www/vhosts/manofmany.com/httpdocs/wp-includes/template-loader.php:75
#20 require_once() called at /var/www/vhosts/manofmany.com/httpdocs/wp-blog-header.php:19
#21 require() called at /var/www/vhosts/manofmany.com/httpdocs/index.php:17November 3, 2016 at 9:35 pm #300409I’ve spoken further with the EWWWW support and they’ve told me that even with EWWW disabled, the theme will still be regenerating images constantly. That will make our pages load slower no matter what. Not as slow as image generation + image optimization, but still a definite slowdown. Disabling EWWW should be a short term solution until we’re able to fix the bug.
November 3, 2016 at 9:36 pm #300410I should add that I think the problem is with the theme constantly regenerating images rather than re-optimising them if that makes sense.
November 7, 2016 at 11:29 am #300719@manofmany – I’ve not seen an actual slow down from the
sf_aq_resize()
function previously.I’ll assign this to Ed to take a look at your function, it looks like it needs a bit of work are you running that on your production site with success?
Thanks.
November 7, 2016 at 11:32 am #300721Hi,
The themes doesn’t have any regeneration process. The only thing that we define is the different size formats that WordPress should create when an image is uploaded.
So only in the moment you upload an image WordPress will create all the different sizes that we registered in the theme and that will be necessary in several different scenarios(Portfolios, featured images, thumbnails, products, team members, etc).
Any regeneration can’t be caused by the theme.
-Rui
November 8, 2016 at 10:25 pm #301088Thanks for getting back to me Rui.
When we dug into the tracelogs of the EWWWW IMage Optimizer, we discovered it was from the Cardinal theme:
The EWWW Image Optimizer plugin extends the base WP_Image_Editor class, which allows it to optimize every image that is created/generated on a WP site. It keeps a record of each image optimized, how many times it has been optimized, when it was last optimized, and if debugging is enabled, it also stores a tracelog from PHP of how the image was created.
The information posted previously is from the tracelogs stored by EWWW I.O.
So, what triggers the warning from EWWW I.O. is when something continuously calls the WP_Image_Editor save() method on the same image file. That is what the Cardinal theme is doing via the sf_aq_resize() function in aq_resizer-1x.php. If you’d like to test it out, you can install EWWW on a test site, and check the ewwwio_images table (sorted by the ‘updates’ column).
November 8, 2016 at 10:55 pm #301091Will have to assigned it to Ed, it’s the better person to reply to this situation.
-Rui
November 9, 2016 at 4:03 pm #301188Currently in contact with the EWWW plugin developer – will follow up with further info.
– Ed
November 9, 2016 at 10:46 pm #301267We have a fix that we’ll be implementing in the next update, thanks!
– Ed
November 9, 2016 at 11:40 pm #301275Thanks so much for letting me know Ed.
Kind regards,
ScottNovember 10, 2016 at 10:46 am #301303Thanks Ed, hope that helps alleviate the issue for you Scott.
– David.
-
Posted in: Cardinal
You must be logged in to reply to this topic.