- Issue created by @isalmanhaider
- π΅π°Pakistan isalmanhaider
It seems the issue originated from the update described in Drupal 7.99 β , as detailed in this change record β .
The problem can be resolved by modifying the validation condition to include
$file->filemime != 'image/svg+xml'
, allowing SVG files to bypass the strict image checks that were causing errors. - Status changed to Needs work
5 months ago 6:27am 1 July 2024 - πΈπ°Slovakia poker10
Thanks for reporting this. I think this is something which needs to be changed in the
svg_image
module in thesvg_image_field_widget_form_alter()
function. Currently the module is altering the#upload_validators
(see here).In π Users are able to upload 0-byte images Fixed a new upload validator was added (see here):
+ $elements[$delta]['#upload_validators']['file_validate_is_image'] = array();
The module can remove the new validator to work as before.
Or you can use
hook_field_widget_form_alter
to remove it in the custom module as well. - π΅π°Pakistan a_z_official
I'm experiencing the same issue. How can I resolve it?
When attempting to upload an SVG file through the node creation form, I receive:
"The specified file 'default.svg' could not be uploaded. The image file is invalid or the image type is not allowed."
Additionally, when trying to set an SVG as the default image, I get:
"'default.svg' could not be uploaded. Only files with the following extensions are allowed: jpg, jpeg, gif, png, txt, doc, xls, pdf, ppt, pps, odt, ods, odp."
Can someone please assist me in resolving this issue? - π΅π°Pakistan a_z_official
In my previous comment, I shared that I was facing the same problem when trying to upload SVG files:
βThe specified file 'default.svg' could not be uploaded. The image file is invalid or the image type is not allowed.β
I also ran into an issue when setting an SVG as the default image:
β'default.svg' could not be uploaded. Only files with the following extensions are allowed: jpg, jpeg, gif, png, etc.β
After digging into the issue, I decided to create a custom Drupal 7 module to fix it. This module, SVG Upload Fix, tweaks the image upload process to skip the validation for SVG files, allowing you to upload SVGs and set them as default images without any errors.
You can check out the module on GitHub: SVG Upload Fix. I hope this helps others who might be dealing with the same issue!