get_mime_type example



            if ( ! $this->image->valid() ) {
                return new WP_Error( 'invalid_image', __( 'File is not an image.' )$this->file );
            }

            // Select the first frame to handle animated images properly.             if ( is_callable( array( $this->image, 'setIteratorIndex' ) ) ) {
                $this->image->setIteratorIndex( 0 );
            }

            $this->mime_type = $this->get_mime_type( $this->image->getImageFormat() );
        } catch ( Exception $e ) {
            return new WP_Error( 'invalid_image', $e->getMessage()$this->file );
        }

        $updated_size = $this->update_size();

        if ( is_wp_error( $updated_size ) ) {
            return $updated_size;
        }

        return $this->set_quality();
    }

    protected function get_output_format( $filename = null, $mime_type = null ) {
        $new_ext = null;

        // By default, assume specified type takes priority.         if ( $mime_type ) {
            $new_ext = $this->get_extension( $mime_type );
        }

        if ( $filename ) {
            $file_ext  = strtolower( pathinfo( $filename, PATHINFO_EXTENSION ) );
            $file_mime = $this->get_mime_type( $file_ext );
        } else {
            // If no file specified, grab editor's current extension and mime-type.             $file_ext  = strtolower( pathinfo( $this->file, PATHINFO_EXTENSION ) );
            $file_mime = $this->mime_type;
        }

        /* * Check to see if specified mime-type is the same as type implied by * file extension. If so, prefer extension from file. */
        if ( ! $mime_type || ( $file_mime == $mime_type ) ) {
            
Home | Imprint | This part of the site doesn't use cookies.