U4-4424 - 6-2beta - Cannot resolve a Url for a media item when there is no 'umbracoFile' property defined.

Created by Damian Green 13 Mar 2014, 11:48:31 Updated by Shannon Deminick 26 May 2014, 01:34:03

Views that were previously working are now throwing errors when i am working with media items and attempting to query the Url param on IPublished content after calling TypedMedia(id).

For example i have a banner on some views and i am checking for the content having a banner set and displaying it.

I think the reason is i have a media item called None that has no file uploaded (so the user can specifically choose No Banner.

So when you create a media item it must not create the umbracoFile property at that point? Or maybe as it is because it was created in an old version? Site did come all the way from v4.6.

Previously I checked the Url property was not empty but now it is throwing the error above when i try and check the property.

What should change here? The way I code the view or an empty string returned from the API?

Comments

Damian Green 13 Mar 2014, 11:52:02

I have tried adding a check for the property but the view will simply not run if i have the code @item.Url in the view so this is a bug i think.

Going to have to try and hack a workaround.


Damian Green 13 Mar 2014, 12:27:33

Managed a workaround by checking the id against my "none".

Will leave this here though as i think it needs clearing up as its a breaking change in my eyes.


Shannon Deminick 25 Mar 2014, 03:26:04

We have been throwing this exception for the Url property for IPublishedContent + media for a very long time (since this rev over a year ago: 1de43347d5f18866d3169bda6f294688dc72142b) So I don't think this is a breaking change.

IPublishedContent didn't exist in v4.6 so I'm not sure what you are referring to? Perhaps are you saying that you've moved from v4.6 which was using razor macros and you are now using IPublishedContent and getting exceptions? If that is the case, it is not breaking, razor macros are obsolete and are different from IPublishedContent so the result in circumstances such as this will be different.


Flavio Spezi 15 May 2014, 14:36:38

@Shandem I have the same issue.

I'm developed website with "Umbraco 6.1.6" and MVC. Website works properly. Now I upgrade the website to "Umbraco 6.2.0": now website returns exceptions when the media don't contains any uploaded file. I'm checking "media.Url == null" to verify if there are a file uploaded to media. Not I receive Exception in this row code.


Eric Schrepel 24 May 2014, 03:41:53

Same issue, just upgraded from 6.1.6 to 6.2; this PartialView code which used to work fine now throws the error "Cannot resolve a Url for a media item when there is no 'umbracoFile' property defined":

@if (item.HasValue("thumbnailImage")) { var image = Umbraco.Media(item.thumbnailImage); var imglink = image.url; }


Shannon Deminick 26 May 2014, 01:32:37

This is very strange, the revision: 1de43347d5f18866d3169bda6f294688dc72142b which contains this exception is part of the following branches/versions:

6.0.7, 6.1.1, 6.1.2, 6.1.3, 6.1.4, 6.1.5, 6.2.0, 6.2.1, 7.0.0

You can easily work around this by checking if the property exists instead of a null check:

if (media.HasProperty("umbracoFile"))


Shannon Deminick 26 May 2014, 01:34:03

and to note that all branches are merged upward to the next branch, so 6.1.5 was merged into 6.1.6


Priority: Normal

Type: Bug

State: Closed

Assignee: Shannon Deminick

Difficulty: Normal

Category:

Backwards Compatible: True

Fix Submitted:

Affected versions: 6.2.0

Due in version: 6.2.0

Sprint:

Story Points:

Cycle: