• Resolved pienoz

    (@pienoz)


    When I insert images with wp_insert_attachment, the .webp file is not created. How to make it automatically created?

Viewing 6 replies - 1 through 6 (of 6 total)
  • Plugin Support adamewww

    (@adamewww)

    Our plugin and optimization would get triggered on wp_generate_attachment_metadata and wp_handle_upload hooks.

    Thread Starter pienoz

    (@pienoz)

    I’m using wp_generate_attachment_metadata . My code :

      $attach_id = wp_insert_attachment( $attachment, $file );
    
        require_once(ABSPATH . 'wp-admin/includes/image.php');
    
        $attach_data = wp_generate_attachment_metadata( $attach_id, $file );
    
        wp_update_attachment_metadata( $attach_id, $attach_data );
    
    Plugin Support adamewww

    (@adamewww)

    Can you try with an image that you know will generate a WebP? Note that our plugin won’t generate a WebP if it isn’t smaller than the original (as that is the point). Is it possible that whatever you were adding via this was already small enough? Can you try uploading it manually and seeing if a WebP image is generated?

    Thread Starter pienoz

    (@pienoz)

    When i upload manualy this image, Webp image is not generated.

    But when I run a mass optimization the Webp files are created.

    Plugin Support adamewww

    (@adamewww)

    That is odd, as it should work to generate a WebP when you upload the image. Can you get a debug log for us:

    1. Go to the support tab and check the box for Debugging and save
    2. Click the link in the support tab that says ‘Clear log’ so we have a clean slate
    3. Try your upload process with a specific image
    4. Go back to the support tab and click the Download Log button
    5. Send that log over to us and the name of the image that you tried to upload
    6. Uncheck the debugging option and save.

    You can post the results in a pastebin or you can email it over to us directly https://ewww.io/contact-us/

    Thread Starter pienoz

    (@pienoz)

    In fact the queue was blocked. After deleting it, it works

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

The topic ‘create webp with wp_insert_attachment’ is closed to new replies.