• Resolved Petar Nizamov

    (@usticia)


    I have the following error when installed your plugin and published the first gallery.

    I want to use it but i have only avif image files and when i upload them in th gallery i get the error: “Warning: exif_imagetype(): stream does not support seeking in /home/customer/www/firewoodshop.co.il/public_html/wp-includes/functions.php on line 3286”

    In Php Fiunctions i have :

    function wp_get_image_mime( $file ) {
    
        /*
    
         * Use exif_imagetype() to check the mimetype if available or fall back to
    
         * getimagesize() if exif isn't available. If either function throws an Exception
    
         * we assume the file could not be validated.
    
         */
    
        try {
    
            if ( is_callable( 'exif_imagetype' ) ) {
    
                $imagetype = exif_imagetype( $file );
    
                $mime      = ( $imagetype ) ? image_type_to_mime_type( $imagetype ) : false;
    
            } elseif ( function_exists( 'getimagesize' ) ) {
    
                // Don't silence errors when in debug mode, unless running unit tests.
    
                if ( defined( 'WP_DEBUG' ) && WP_DEBUG
    
                    && ! defined( 'WP_RUN_CORE_TESTS' )
    
                ) {
    
                    // Not using wp_getimagesize() here to avoid an infinite loop.
    
                    $imagesize = getimagesize( $file );
    
                } else {
    
                    // phpcs:ignore WordPress.PHP.NoSilencedErrors
    
                    $imagesize = @getimagesize( $file );
    
                }
    
                $mime = ( isset( $imagesize['mime'] ) ) ? $imagesize['mime'] : false;
    
            } else {
    
                $mime = false;
    
            }
    
            if ( false !== $mime ) {
    
                return $mime;
    
            }
    
            $magic = file_get_contents( $file, false, null, 0, 12 );
    
            if ( false === $magic ) {
    
                return false;
    
            }
    
            /*
    
             * Add WebP fallback detection when image library doesn't support WebP.
    
             * Note: detection values come from LibWebP, see
    
             * https://github.com/webmproject/libwebp/blob/master/imageio/image_dec.c#L30
    
             */
    
            $magic = bin2hex( $magic );
    
            if (
    
                // RIFF.
    
                ( str_starts_with( $magic, '52494646' ) ) &&
    
                // WEBP.
    
                ( 16 === strpos( $magic, '57454250' ) )
    
            ) {
    
                $mime = 'image/webp';
    
            }
    
        } catch ( Exception $e ) {
    
            $mime = false;
    
        }
    
        return $mime;
    
    }
    
    /**
    
     * Retrieves the list of mime types and file extensions.
    
     *
    
     * @since 3.5.0
    
     * @since 4.2.0 Support was added for GIMP (.xcf) files.
    
     * @since 4.9.2 Support was added for Flac (.flac) files.
    
     * @since 4.9.6 Support was added for AAC (.aac) files.
    
     *
    
     * @return string[] Array of mime types keyed by the file extension regex corresponding to those types.
    
     */

    The page I need help with: [log in to see the link]

Viewing 3 replies - 1 through 3 (of 3 total)
  • Thread Starter Petar Nizamov

    (@usticia)

    Can someone help me with this? The plugin is not working with the newest and best image file format – AVIF.

    Plugin Support elviiso

    (@elviiso)

    Hi @usticia,

    I’m currently in the process of investigating this issue. I will get back to you soon with a response. Thanks.

    Kind regards,
    Elvis.

    Plugin Support elviiso

    (@elviiso)

    Hi @usticia

    The error message you’re encountering, “Warning: exif_imagetype(): stream does not support seeking”, is related to the exif_imagetype() function in PHP. This function reads the first bytes of an image to determine its type by checking its signature. However, the function may throw a warning if it encounters a problem with the file’s path or if the file cannot be accessed in the required manner for exif_imagetype() to work properly.

    At this point, it’s important to note that WordPress does not support AVIF images natively. The warning is likely triggered because AVIF, which is currently not supported natively by WordPress, may not be fully supported or recognized by the PHP function exif_imagetype() or by the WordPress environment plugin you are using. The message suggests that the function is unable to seek through the stream of data representing the AVIF image, which is crucial for it to read the first few bytes of the image to determine its type.

    In this situation, even though I understand that you want to use a better image format, the best recommendation would be to advise you to switch to images with the recommended/supported image format that WordPress natively supports until WordPress officially supports AVIF images natively.

    Thanks.

    Kind regards,
    Elvis.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘exif_imagetype php error’ is closed to new replies.