I have some .svg images that I need to upload to the Media Section. If I use the Drag & Drop Upload then the image is uploaded but it it treated as a media type of "File" and not "Image". The image is uploaded to the media section, but it is not accessible via @Model.Media("brandLogo", "umbracoFile") .
This site is running Umbraco 6.1.6.
If I create the Media item individually with a Media Type of "Image" and then us "Choose File" to upload the image I get the following error:
Parameter is not valid.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.ArgumentException: Parameter is not valid.
Source Error:
An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.
I don't think that anyone has succeeded achieving this as media - Perhaps it would be a good idea to make a feature request for this at the issue tracker
How are you going to use the .svg files? Is it for logos etc. or is it for content? Just wondering if it would be an absolute no go to upload as the "file" type as a workaround?
Agreed - But just wondering if uploading as File would be a possible workaround. I have not been using .SVG graphics in my Umbraco sites yet so just curious :) (Voted the issue btw).
Sure - If you go into the media section and right click on a folder you can choose to manually create a file item from the dropdown that appears - Now try uploading your .svg file.
Also make sure to add the proper SVG mime type in your web.config static settings so you make sure that the server knows about the correct mime type for dealing with it.
at System.Drawing.Image.FromStream(Stream stream, Boolean useEmbeddedColorManagement, Boolean validateImageData)
at Umbraco.Web.PropertyEditors.FileUploadPropertyValueEditor.ConvertEditorToDb(ContentPropertyData editorValue, Object currentValue)
at Umbraco.Web.Editors.ContentControllerBase.MapPropertyValues[TPersisted](ContentBaseItemSave`1 contentItem)
at Umbraco.Web.Editors.MediaController.PostSave(MediaItemSave contentItem)
at lambda_method(Closure , Object , Object[] )
at System.Web.Http.Controllers.ReflectedHttpActionDescriptor.ActionExecutor.<>c__DisplayClass13.<GetExecutor>b__c(Object instance, Object[] methodParameters)
at System.Web.Http.Controllers.ReflectedHttpActionDescriptor.ActionExecutor.Execute(Object instance, Object[] arguments)
at System.Threading.Tasks.TaskHelpers.RunSynchronously[TResult](Func`1 func, CancellationToken cancellationToken)
This issue is caused by having svg in the imageFileTypes list in umbracoSettings.config. Without svg in this list umbraco doesn't try creating a thumbnail from the avg and you're able to upload the image without error.
Aaah, nice catch - Did not think about that even though it's mentioned that it was added in the first post.
So the issue should probably be changed as well in regards to that it should be possible to have thumbnails of .svg file rather than it's an issue uploading .svg files if it has not already been done.
In Umbraco 7.4 I was still getting the same error so in order to allow SVG files to be uploaded to media section you need to remove SVG from <disallowedUploadFiles> tag in UmbracoSettings.config file.
In Umbraco 7.4 I was still getting the same error so in order to allow SVG files to be uploaded to media section you need to remove SVG from
Perfect!
Perhaps someone from the Umbraco core team could comment on why it's disallowed in the first place? Seems strange to me that you'd want to disable something that's so commonplace now on the web these days.
Looks like a catch 22 situation: in order to be pick SVG files with a Media Picker we must to add SVG to the imageFileTypes list, but adding SVG to the imageFileTypes list rise an error when uploading SVG files...
Error Uploading SVG image to Media Section
I have some .svg images that I need to upload to the Media Section. If I use the Drag & Drop Upload then the image is uploaded but it it treated as a media type of "File" and not "Image". The image is uploaded to the media section, but it is not accessible via @Model.Media("brandLogo", "umbracoFile") .
This site is running Umbraco 6.1.6.
If I create the Media item individually with a Media Type of "Image" and then us "Choose File" to upload the image I get the following error:
Parameter is not valid.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.ArgumentException: Parameter is not valid.
Source Error:
An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.
Stack Trace:
My umbracoSettings.config includes .svg as an image type:
<imageFileTypes>jpeg,jpg,gif,bmp,png,tiff,tif,svg</imageFileTypes>
I have checked my Mime Types. Both IIS and my web.config specify this extension.
<staticContent>
<remove fileExtension=".svg" />
<mimeMap fileExtension=".svg" mimeType="image/svg+xml" />
</staticContent>
Is there something else that needs to be done for svg images to work with Umbraco?
Did you ever solve this? Its still an issue in v7.2
Hi Guys
I don't think that anyone has succeeded achieving this as media - Perhaps it would be a good idea to make a feature request for this at the issue tracker
How are you going to use the .svg files? Is it for logos etc. or is it for content? Just wondering if it would be an absolute no go to upload as the "file" type as a workaround?
/Jan
I raised this as a bug, svg should be supported. http://issues.umbraco.org/issue/U4-6008
Agreed - But just wondering if uploading as File would be a possible workaround. I have not been using .SVG graphics in my Umbraco sites yet so just curious :) (Voted the issue btw).
/Jan
Jan, could you further explain 'uploading as File' please?
Hi Chris
Sure - If you go into the media section and right click on a folder you can choose to manually create a file item from the dropdown that appears - Now try uploading your .svg file.
Also make sure to add the proper SVG mime type in your web.config static settings so you make sure that the server knows about the correct mime type for dealing with it.
/Jan
Ah, OK. That gives me the following exception:
Received an error from the server
An error occurred
Parameter is not valid.
Exception Details:
System.ArgumentException: Parameter is not valid.Stacktrace:
Hi Chris
Hmm, does it work if you try uploading something else? Like a PDF, Word or Excel file?
Just trying to figure out if it's for some reason failing when trying to upload certain file types or if it's a general issue.
/Jan
This issue is caused by having svg in the imageFileTypes list in umbracoSettings.config. Without svg in this list umbraco doesn't try creating a thumbnail from the avg and you're able to upload the image without error.
Hi Chris
Aaah, nice catch - Did not think about that even though it's mentioned that it was added in the first post.
So the issue should probably be changed as well in regards to that it should be possible to have thumbnails of .svg file rather than it's an issue uploading .svg files if it has not already been done.
/Jan
In Umbraco 7.4 I was still getting the same error so in order to allow SVG files to be uploaded to media section you need to remove SVG from
<disallowedUploadFiles>
tag inUmbracoSettings.config
file.Ali
Perfect!
Perhaps someone from the Umbraco core team could comment on why it's disallowed in the first place? Seems strange to me that you'd want to disable something that's so commonplace now on the web these days.
I have removed it but i still have problem
I've submitted a PR to the issue which can be tracked here: http://issues.umbraco.org/issue/U4-6008
I can now upload .svg's, but I cannot select them with a picker :s anyone?
Hi,
did anybody managed to solve this one?
Looks like a catch 22 situation: in order to be pick SVG files with a Media Picker we must to add SVG to the imageFileTypes list, but adding SVG to the imageFileTypes list rise an error when uploading SVG files...
/M
How is this still an issue? Or is there any change?
Surely a thumbnail could be created for an svg, or not generated and use the original file as the thumbnail view.
is working on a reply...