• Resolved anissneo

    (@anissneo)


    Hi,

    If the plugin is activated, when deleting an image, an error appears: Error in deleting the attachment.

    The plugin was registering a delete_attachment hook that called a method webpc_remove_original() in the main class, but this method didn’t exist. This caused a 500 error when trying to delete an image.

    Solution

    Add the missing method webpc_remove_original($attachment_id) to the WEBPCbySheepFish class. This method simply calls the static method of the same name in the WebpC_Remover class.

    Add method in webp-conversion.php (after webpc_remove_originals_selected) – Line 674 (just before function webpc_convert_single) :

    <?php
    /**
    * Hook callback for when an attachment is deleted.
    * Removes the backup/original file associated with the attachment.
    *
    * @param int $attachment_id The attachment ID being deleted.
    * @return void
    */
    public function webpc_remove_original($attachment_id): void
    {
    WebpC_Remover::webpc_remove_original($attachment_id);
    }

    Root Cause

    Line 91 in webp-conversion.php registers the hook:

    add_action('delete_attachment', [$this, 'webpc_remove_original']);

    But the method webpc_remove_original() was not defined in the class, causing a fatal error when WordPress tries to delete an attachment.

    Regards

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

You must be logged in to reply to this topic.