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 :)
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.
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?
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.
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
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.
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?
is working on a reply...