• Resolved smerriman

    (@smerriman)


    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 don’t 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 5 years, 1 month ago by smerriman.
Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter smerriman

    (@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.

    Plugin Support Hai Zheng⚡

    (@hailite)

    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 don’t need to do any extra operation as we hooked the function wp_update_attachment_metadata.

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

The topic ‘Optimise dynamically generated thumbnails?’ is closed to new replies.