{"record":{"id":"2be9b45aaf61f4b5","repo":"Intervention/image","slug":"unable-to-create-media-type-from-identifier","errorCode":null,"errorMessage":"Unable to create media type from \"{identifier}\"","messagePattern":"Unable to create media type from \"(.+?)\"","errorType":"exception","errorClass":"InvalidArgumentException","httpStatus":null,"severity":"error","filePath":"src/MediaType.php","lineNumber":85,"sourceCode":"\n        if ($identifier instanceof FileExtension) {\n            try {\n                return $identifier->mediaType();\n            } catch (NotSupportedException $e) {\n                throw new InvalidArgumentException(\n                    'Unable to create media type from \"' . $identifier->value . '\"',\n                    previous: $e,\n                );\n            }\n        }\n\n        try {\n            $type = self::from(strtolower($identifier));\n        } catch (Error) {\n            try {\n                $type = FileExtension::from(strtolower($identifier))->mediaType();\n            } catch (Error | NotSupportedException) {\n                throw new InvalidArgumentException('Unable to create media type from \"' . $identifier . '\"');\n            }\n        }\n\n        return $type;\n    }\n\n    /**\n     * Try to create media type from given identifier and return null on failure.\n     */\n    public static function tryCreate(string|self|Format|FileExtension $identifier): ?self\n    {\n        try {\n            return self::create($identifier);\n        } catch (InvalidArgumentException) {\n            return null;\n        }\n    }\n","sourceCodeStart":67,"sourceCodeEnd":103,"githubUrl":"https://github.com/Intervention/image/blob/5598b9e39751c34afc5cdee84abef77f92c26f68/src/MediaType.php#L67-L103","documentation":"Error \"Unable to create media type from \"{identifier}\"\" thrown in Intervention/image.","triggerScenarios":"Thrown at src/MediaType.php:85 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Pass a valid media type string such as \"image/jpeg\" or a file path with a known extension","Check for typos in the media type (e.g. 'image/jpg' is not a registered media type, use 'image/jpeg')","Use MediaType::tryFrom or the Format enum when the value is dynamic"],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"5598b9e39751c34afc5cdee84abef77f92c26f68","analyzedAt":"2026-08-23T02:17:31.068Z","schemaVersion":2},"datasetVersion":"2026-08-23T08:06:27.607Z"}