Copied to clipboard

Flag this post as spam?

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


  • Danny Blatant 91 posts 358 karma points
    Sep 19, 2014 @ 16:47
    Danny Blatant
    0

    umbracoFile not behaving on Publish/Deploy

    Hi everyone,

    I'm developing a site and prior to deploying to dev and stage servers I am doing some dry runs on publishing and deploying the site. I've encountered an issue with umbracoFile, which works fin when ran in debug, via IIS8express but malfunctions once deployed to my IIS7 server.

    I am using Umbraco7, VS 2013, SQL Server, IIS7 & IIS8express.

    Simply put I am retrieving typed image data from a property like so :

    var test = Umbraco.TypedMedia((int)award.GetPropertyValue("image")).GetPropertyValue("umbracoFile");
    

    When I run the site (Release or Debug) and print out 'test' I get exactly what I expect, the path to the image (for example '/media/1001/image/png'). However Once Published and Deployed, while everything else is working swimmingly the same code churns out this :

    {
      "src": "/media/1001/image.png",
      "crops": []
    }
    

    As you can see, this appears to be the right object, but serialised!

    So my questions are; am I missing a reference or assembly in my package (I can imagine that an umbracoFile object is missing ergo the default output when echoed is not present, resulting in serialised object)?

    Have I missed an include, which makes sense as this only happens on publish?

    Perhaps I'm missing a config change in my web/umbraco config, seems unlikely as the path is relative and the root is set fine?

    Am I missing some code or include, seems to work fine locally?

    Can anyone help?

    It may be a publishing issue, something not included/referenced however I have spent some time today reviewing my references and included files and can't find anything umbraco file/media related...

    All my thanks in advance for any suggestings or advise!

    Danny "Blatant"

  • Dan Lister 416 posts 1974 karma points c-trib
    Sep 19, 2014 @ 16:51
    Dan Lister
    0

    Hi Danny,

    Are you using the Image Cropper for the data type of that property by any chance? The only reason I ask is because your serialised data contains an empty collection.

    If you are then I'd suggest using the GetGropUrl() method and adding some crops to your data type.

    Thanks, Dan.

  • Danny Blatant 91 posts 358 karma points
    Sep 19, 2014 @ 16:59
    Danny Blatant
    0

    Hi Dan,

    I am and I'm not! I followed the guide and set up Image Cropper, and is is indeed the Property Type not the datatype! its Umbraco.MediaPicker(sorry I didn't mention the DataType). However I am not actually 'using' the type, as I don't require a crop in this case, I just based my property on it.

    You do give me an idea though, I will re-check to see if Image Cropper is included in my deploy properly.

    I'll also try the GetCropUrl method, I'll see if I can set up a 'no crop' crop, if you see what I mean (thse are logo's so can not be cropped, just resized hence imagegen). And I'll update on my success, however I worked this method first time before I moved focus from Image Crop to imagegen and the reason I ended up with the GetPropertyValue("umbracoFile") method was (I suspect) because it was the first method to give me the URL properly. Regardless I'm about to try that out!

    It will be a completely suitable workaround, however I would like to get to the bottom of why the GetPropertyValue method works locally but not after publish. If anyone has any more thoughts or suggestions please let me know!

    Thanks,

    Danny "Blatant"

  • Danny Blatant 91 posts 358 karma points
    Sep 19, 2014 @ 17:19
    Danny Blatant
    0

    As an update,

    When I call GetCropUrl("image") I get a strange query string as so :

    /?mode=pad&rnd=130549266000000000
    

    So I'm guessing I need to look into this some more...

    I may have mis-lead when I said I am using ImageCropper, it is installed but this field (alias "image") is a straight Umbraco.MediaPicker datatype, not umbraco.ImageCropper...

    So I reason that this is why I'm not using GetCropUrl in this case.

    Any more thought?

    Regards,

    Danny "Blatant"

  • Danny Blatant 91 posts 358 karma points
    Sep 19, 2014 @ 18:33
    Danny Blatant
    0

    Another Ammendum,

    Seems when I inspect the type of object returned by GetPropertyValue("image") I get 2 different things! On my localhost in debug I get

    System.String
    

    Whereas once deployed I get

    Newtonsoft.Json.Linq.JObject
    

    I don't know what this 'means', but perhaps it leans to incorrect references again?

    Regards,

    Danny "Blatant"

  • Danny Blatant 91 posts 358 karma points
    Sep 19, 2014 @ 20:04
    Danny Blatant
    100

    I have resolved my issues eventually!

    THe origional problem is that while deveoping I uploaded my media before installing ImageCropper. This resulted in my origional code working and returning umbracoFile property. I got a clue from another post which I can't find that mentioned you need to 'touch' or resave an image for it to be saved as the ImageCropper type of image, and once I did this on my dev the return resembled my published version.

    I can only assume that publishing somehow resaved these entries.

    Following this I was able to forget about the simple string return and focus on handling the JObject being returned. Here's a summary of my solution.

    @using Newtonsoft.Json.Linq
    
    JObject test = Umbraco.TypedMedia((int)item.GetPropertyValue("image")).GetPropertyValue<JObject>("umbracoFile");
    
    var output = "<img src=\"/imagegen.ashx?image=" + awardImage["src"] + "&height=140\" alt=\"ALT\" />";
    

    Thanks for the advice, hope this helps someone somehow. Watch out iif you have Media added before installing ImageCropper!

    Cheers all,

    Danny "Blatant"

  • Sanjeev 1 post 71 karma points
    May 20, 2016 @ 12:12
    Sanjeev
    0

    Thank you all for giving some pointers.. Below is my discovery

    Content of the umbracoFile is decided on what type of property editor is attached to that field. You can check that by navigating to the umbraco admin > Settings > Media Types > Image > umbracoFile

    If the editor attached is ImageCropper, this field will hold Json string with the data. You delete this definition and add new umbracoFile attaching to Umbraco.UploadField editor then a string is saved..

Please Sign in or register to post replies

Write your reply to:

Draft