Umbraco v6 Upgrade UmbracoWidth and UmbracoHeight Not set
Hey Guys,
I have found that since upgrading my old umbraco 4.7.2 site to Umbraco v6.0.2 when a media item is uploaded to the media section either using the drag and drop or the manual method the umbracoWidth, umbracoHeight and type and size properties are not being set.
This seems to be having a knock on effect in the insert media in the RTE when trying to adjust the size of images prior to insertion.
I have seen an issue on the bug tracker about the umbracoFile being empty but couldn't see anything about hte other properties. (http://issues.umbraco.org/issue/U4-1937)
I'm having a similar issue with v6.1.2. What I've just found, be sheer luck, is first "saving" then "save and publish" and then the values appear. Odd.
So I had a similar issue. I resolved it by changing my code from...
var mediaObject = ApplicationContext.Current.Services.MediaService.GetById(Convert.ToInt32(param));
var filePath = mediaObject.Properties["umbracoFile"].Value as string;
var width = mediaObject.Properties["umbracoWidth"].Value as int?;
var height = mediaObject.Properties["umbracoHeight"].Value as int?;
<div style="background-image:url('@filePath'); height: @height; width:@width;" ></div>
to
var mediaObject = ApplicationContext.Current.Services.MediaService.GetById(Convert.ToInt32(param));
var filePath = mediaObject.Properties["umbracoFile"].Value as string;
var width = mediaObject.Properties["umbracoWidth"].Value.ToString();
var height = mediaObject.Properties["umbracoHeight"].Value.ToString();
<div style="background-image:url('@filePath'); height: @height ; width:@width;" ></div>
Notice the .toString rather than relying on casting to int.
So just to elaborate. It seems as though "mediaObject.Properties["umbracoWidth"].Value" is of type object, which does not convert nicely to int. However casting it to string then int solves, although I did not do that in my code as I really just needed the string anyway.
Umbraco v6 Upgrade UmbracoWidth and UmbracoHeight Not set
Hey Guys,
I have found that since upgrading my old umbraco 4.7.2 site to Umbraco v6.0.2 when a media item is uploaded to the media section either using the drag and drop or the manual method the umbracoWidth, umbracoHeight and type and size properties are not being set.
This seems to be having a knock on effect in the insert media in the RTE when trying to adjust the size of images prior to insertion.
I have seen an issue on the bug tracker about the umbracoFile being empty but couldn't see anything about hte other properties. (http://issues.umbraco.org/issue/U4-1937)
Does anyone have any ideas?
L
I'm having a similar issue with v6.1.2. What I've just found, be sheer luck, is first "saving" then "save and publish" and then the values appear. Odd.
Hi,
So I had a similar issue. I resolved it by changing my code from...
to
Notice the .toString rather than relying on casting to int.
So just to elaborate. It seems as though "mediaObject.Properties["umbracoWidth"].Value" is of type object, which does not convert nicely to int. However casting it to string then int solves, although I did not do that in my code as I really just needed the string anyway.
Thanks for the tip Glenn, I'll give that a shot.
is working on a reply...