Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Lachlann 344 posts 626 karma points
    Mar 27, 2013 @ 12:22
    Lachlann
    0

    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

  • Sean 64 posts 116 karma points
    Jul 10, 2013 @ 22:43
    Sean
    0

    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.

  • Glenn 28 posts 101 karma points
    Sep 05, 2013 @ 04:26
    Glenn
    0

    Hi,

    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.

  • Sean 64 posts 116 karma points
    Sep 27, 2013 @ 18:08
    Sean
    0

    Thanks for the tip Glenn, I'll give that a shot.

Please Sign in or register to post replies

Write your reply to:

Draft