Copied to clipboard

Flag this post as spam?

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


  • Zakhar 171 posts 397 karma points
    Sep 28, 2012 @ 15:08
    Zakhar
    0

    Media picker incosistency in storing data

    Hi guys,

    I noticed a problem with Umbraco (at the moment I use 4.7.2) when it comes to storing media picker value.

    In my case sometimes it stores media node ID and sometimes url to the media file, so when I use `item.GetProperty("picture").Value`

    in some cases it return something like "/media/2456/empty_placeholder.png" and sometimes it returns "1859".

    That is really frustrating and breaks the site (I'm getting "Error loading Razor Script" error when trying to parse integer)

    I noticed that if I delete umbraco.config the problem goes away (it is consistent in newly generated file).

    Has anyone else noticed this problem ot it's only me? Why can that be and how to solve it?

    Thank you.

  • Jan Skovgaard 11280 posts 23678 karma points MVP 11x admin c-trib
    Sep 28, 2012 @ 18:16
    Jan Skovgaard
    0

    Hi Zakhar

    From from you're writing above I suspect that the issue is that sometimes the media picker property is being used (which returns an id of a media node) and sometimes an image has been uploaded directly on the document type using the "upload" property (Which returns the full path to the image in this case).

    In your Razor script I suppose you could make a condition and do a check on the property you're trying to fetch a value from. If the alias is mapped to an upload property then simply write out the url and if it's mapped to a media picker then fetch the media using the GetMedia extension.

    Can you confirm this setup? I've never heard anyone experiencing issues as mentioned above when using a media picker consistently :)

    /Jan

  • Zakhar 171 posts 397 karma points
    Oct 02, 2012 @ 11:23
    Zakhar
    0

    Hi Jan,

    Sorry for getting back so late, I was busy with another project. This property is a Media picker, so when I click Choose I can only pick a media file from Media. There is no option to upload a file directly from there, how can it be used as an "Upload"? I'm a bit confused here.

     

    Zakhar.

  • Dan Diplo 1554 posts 6205 karma points MVP 6x c-trib
    Oct 02, 2012 @ 15:34
    Dan Diplo
    0

    The standard MediaPicker always stores a numeric ID in my experience. You should be able to check this by looking in the umbraco.config and seeing what value is stored for the property. Can you check that is the case?

Please Sign in or register to post replies

Write your reply to:

Draft