• I noticed today tat image optimisation isn’t working automatically on upload and I can’t get the bulk optimiser to do anything either.

    Looking at the history of my images it was working fine until the end of October so perhaps something happened after an update.

    I’ve deactivated all plugins and reverted to a core theme (TwentyFifteen) and the issue is still present.

    Looking in the postmeta for my images there is an error code of 451 for Optimus – any ideas on the cause and how to fix this?

Viewing 4 replies - 1 through 4 (of 4 total)
  • Thread Starter Matt Robinson

    (@mattyrob)

    I think I’ve found a bug while investigating my problem. If an image has had an optimisation attempted but an error has been recorded the current SQL query no longer selects it when manually trying to optimise it again.

    Amending the query to the following fixes that – but there may be a better way.

    $query = "SELECT DISTINCT $wpdb->posts.ID, $wpdb->posts.post_title, $wpdb->posts.post_mime_type
                FROM $wpdb->posts, $wpdb->postmeta
                WHERE $wpdb->posts.ID = $wpdb->postmeta.post_id
                    AND $wpdb->posts.post_type = 'attachment'
                    AND $wpdb->posts.post_mime_type LIKE 'image/%'
                    AND ($wpdb->postmeta.meta_key = '_wp_attachment_metadata'
                    AND $wpdb->postmeta.meta_value NOT LIKE '$optimus_query'
    		OR $wpdb->postmeta.meta_value NOT LIKE '%error%')
                    $id_query
                ORDER BY $wpdb->posts.ID DESC";
    Thread Starter Matt Robinson

    (@mattyrob)

    A better fix is as follows as the above introduces another bug:

    if ( $options['webp_convert'] ) {
        $optimus_query = '%optimus%webp";i:1%';
    } else {
        $optimus_query = '%optimus%profit";s:2%';
    }

    Thanks for the feedback.

    To clarify, were you receiving any error codes from Optimus in your WordPress dashboard when trying to optimize an image? Was this occurring for all new images that were uploaded as well?

    Thread Starter Matt Robinson

    (@mattyrob)

    @codyarsenault

    No errors when adding media or publishing posts but if I try to manually optimise the images now from the Media Library (after applying my fix above so they do actually attempt to update) I get an error code 451 there also.

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

The topic ‘Optimisation not working since November’ is closed to new replies.