src/Graby.php
private function getMimeActionInfo(array $headers)
    {
        $contentType = isset($headers['content-type']) ? strtolower($headers['content-type']) : '';

        // check if action defined for returned Content-Type
        $info = [
            'mime' => '',
        ];

        if (preg_match('!\s*(([-\w]+)/([-\w\+]+))!im', $contentType, $match)) {
            // look for full mime type (e.g. image/jpeg) or just type (e.g. image)
            // match[1] = full mime type, e.g. image/jpeg
            // match[2] = first part, e.g. image
            // match[3] = last part, e.g. jpeg
            $info['mime'] = trim($match[1]);
            $info['type'] = trim($match[2]);
            $info['subtype'] = trim($match[3]);

            foreach ([$info['mime'], $info['type']] as $mime) {
                if (isset($this->config['content_type_exc'][$mime])) {
                    $info['action'] = $this->config['content_type_exc'][$mime]['action'];
                    $info['name'] = $this->config['content_type_exc'][$mime]['name'];

                    break;
                }
            }
        }

        return $info;
    }
private function getMimeActionInfo(array $headers)
    {
        $contentType = isset($headers['content-type']) ? strtolower($headers['content-type']) : '';

        // check if action defined for returned Content-Type
        $info = [
            'mime' => '',
        ];

        if (preg_match('!\s*(([-\w]+)/([-\w\+]+))!im', $contentType, $match)) {
            // look for full mime type (e.g. image/jpeg) or just type (e.g. image)
            // match[1] = full mime type, e.g. image/jpeg
            // match[2] = first part, e.g. image
            // match[3] = last part, e.g. jpeg
            $info['mime'] = trim($match[1]);
            $info['type'] = trim($match[2]);
            $info['subtype'] = trim($match[3]);

            foreach ([$info['mime'], $info['type']] as $mime) {
                if (isset($this->config['content_type_exc'][$mime])) {
                    $info['action'] = $this->config['content_type_exc'][$mime]['action'];
                    $info['name'] = $this->config['content_type_exc'][$mime]['name'];

                    break;
                }
            }
        }

        return $info;
    }
private function getMimeActionInfo ( array $ headers ) { $ contentType = isset ( $ headers [ 'content-type' ] ) ? strtolower ( $ headers [ 'content-type' ] ) : '' ; // check if action defined for returned Content-Type $ info = [ 'mime' => '' , ] ; if ( preg_match ( '!\s*(([-\w]+)/([-\w\+]+))!im' , $ contentType , $ match ) ) { // look for full mime type (e.g. image/jpeg) or just type (e.g. image) // match[1] = full mime type, e.g. image/jpeg // match[2] = first part, e.g. image // match[3] = last part, e.g. jpeg $ info [ 'mime' ] = trim ( $ match [ 1 ] ) ; $ info [ 'type' ] = trim ( $ match [ 2 ] ) ; $ info [ 'subtype' ] = trim ( $ match [ 3 ] ) ; foreach ( [ $ info [ 'mime' ] , $ info [ 'type' ] ] as $ mime ) { if ( isset ( $ this -> config [ 'content_type_exc' ] [ $ mime ] ) ) { $ info [ 'action' ] = $ this -> config [ 'content_type_exc' ] [ $ mime ] [ 'action' ] ; $ info [ 'name' ] = $ this -> config [ 'content_type_exc' ] [ $ mime ] [ 'name' ] ; break ; } } } return $ info ; }
Based on content-type http header, decide what to do.

@param array $headers All headers from the response

@return array With keys: 'mime', 'type', 'subtype', 'action', 'name'
e.g. array('mime'=>'image/jpeg', 'type'=>'image', 'subtype'=>'jpeg', 'action'=>'link', 'name'=>'Image')
Based on content - type http header decide what to do .