Wordpress LScache Plugin: Optimise dynamically generated thumbnails?
Last Updated on: Wed, 15 Apr 2026 00:00:02 I am using (as an example) a custom block where you provide an image and it generates a thumbnail on save, with rough code along the following lines: $file = get_attached_file($id) $editor = wp_get_image_editor($file) if ( ! is_wp_error( $editor ) ) $sizes = $editor->multi_resize(array(newsize=>array(width=>240,height=>240,crop=>true))) $meta[sizes] = array_merge($meta[sizes],$sizes) wp_update_attachment_metadata($id,$meta) I dont want to use add_image_size and have it generate this size for every single image uploaded to the site, only this specific one. Is there a way to tell LiteSpeed to optimise it, without needing to rescan the entire site manually to look for missing thumbnails? Could I manually add the image to the litespeed_img_optm table, or is there a function I could call? This topic was modified 1 year, 8 months ago by smerriman. Just to be precise, the image already gets added to the table (when you upload it). But the dynamic thumbnail does not. And the rescan process takes a long time with a large site, so just looking for a quick workaround to get just one specific thumbnail in the queue. At the initial thinking, I think you can directly insert those data into img_optm table, make a similar function like _save_raw(). Later on, I realized this is a good case to improve the image gathering process. Therefore, this part is improved in v3.7-rc25 (https://github.com/litespeedtech/lscache_wp/commit/41fa5a7882f2ee6e49e94c1fda186d3fe1beab8b). Please give it a try. You dont need to do any extra operation as we hooked the function wp_update_attachment_metadata.
LiteCache Rush: Speed comes from using less, not from doing it faster
Reference