- Issue created by @tcrawford
- @tcrawford opened merge request.
- Status changed to Needs review
over 1 year ago 3:27pm 10 April 2023 - 🇮🇳India Ranjit1032002
Created a patch for the issue mentioned, please review.
Thank You. - 🇺🇸United States smustgrave
This issue was started in an MR and should remain there.
Thank you @tcrawford for steps to reproduce. This will need a test case showing the issue.
- Status changed to Needs work
over 1 year ago 1:47pm 18 April 2023 - First commit to issue fork.
- last update
over 1 year ago 30,103 pass, 2 fail - 🇮🇹Italy mondrake 🇮🇹
This issue is a bit obscure to me... the GD toolkit does not support SVG images, since GD does not (and likely will never) support vectorial graphic formats. Normally unsupported file formats would fail much earlier than where you are proposing to fix, i.e. in file extension validations, where the file extension of the file to-be-uploaded is matched against the file extensions that an image toolkit supports. I'm not sure how you can have an
entity that supports svg extensions
? Maybe with contrib?
- 🇨🇭Switzerland tcrawford
@mondrake You are right. The issue only occurs for me in projects using the drupal/rokka module, which uses its own RokkaToolkit that extends the GDToolkit. Rokka supports the svg extension, but there is no related type and so we see the type error.
/** * Get the mime type. * * @return string * Mime type. */ public function getMimeType(): string { $mime_type = $this->getType() ? image_type_to_mime_type($this->getType()) : ''; // GD library does not support SVG, but Rokka does. So we will trick the // toolkit and detect SVG as a mime time the first time the file is uploaded // to the tmp folder. If we detect an SVG image, we allow the upload. if (empty($mime_type)) { $uri = $this->getSource(); if ($uri && file_exists($uri) && strpos($uri, 'rokka://') === FALSE) { $rokka_additional_allowed_mime_types = ['image/svg', 'image/svg+xml']; $mime_type_guessed = mime_content_type($uri); if (in_array($mime_type_guessed, $rokka_additional_allowed_mime_types)) { $mime_type = $mime_type_guessed; } } } return $mime_type; }
I guess we need to get have the Rokka Toolkit modified to override the load() method also and check that getType() is set.
I am closing this issue as 'cannot reproduce' as it only occurs in combination with the RokkaToolkit.
- Status changed to Closed: cannot reproduce
3 months ago 11:22am 17 September 2024