Multisite bulk image compression only compresses full-size version of image
-
Hi! I’m using free version 3.3.0 and noticed that there seems to be a problem with bulk compressing images on multisites. When bulk compressing only the full size image gets compressed whereas compressing a single image directly from the media library does compress all registered image sizes.
Digging through the code I found that there seems to be a missing switch to the correct blog in
includes\class-updraft-smush-task.php
. Line 77 reads:$files = array_merge(array('full' => $file_path), WPO_Image_Utils::get_attachment_files($attachment_id));
Comparing with lines 52 through 58, I replaced line 77 with this:
if (is_multisite()) { switch_to_blog($this->get_option('blog_id', 1)); $files = array_merge(array('full' => $file_path), WPO_Image_Utils::get_attachment_files($attachment_id)); restore_current_blog(); } else { $files = array_merge(array('full' => $file_path), WPO_Image_Utils::get_attachment_files($attachment_id)); }
Surely there is a better fix but i tried this with a few images and it seemed to work.
The media library on the affected multisite consists of a few thousand images, so I wanted to ask wether this is indeed a correct fix before I start compressing with unknown side effects.
- The topic ‘Multisite bulk image compression only compresses full-size version of image’ is closed to new replies.