U4-579 - Empty custom properties returned as DynamicXml on Media items in Razor and XSLT

Created by Sebastiaan Janssen 19 Aug 2012, 14:54:17 Updated by Jeroen Breuer 14 May 2013, 07:18:37

umbraco v 4.7.2 (Assembly version: 1.0.4500.21031) umbraco v 4.8 umbraco v 4.9.1 umbraco v.4.10.1 umbraco v.6.0.1

There is still problems with empty strings on Medias

See this old closed issue: http://umbraco.codeplex.com/workitem/30504?ProjectName=umbraco

The example below is updated with the latest (I know of) Razor method to get media. Using "DynamicMedia".


If you add a custom TextString property to a Media Item and then retrieve it's value it is returned as type DynamicXml. I would expect it to be a string or perhaps null or DynamicNull.

Steps to reproduce:

Go to Settings > Media Types in Umbraco 4.7.2 back-office. Add a custom TextString property to the Image media type with an alias of AlternativeText. Create an image in the Media folder and leave the AlternativeText field empty. Make a note of the id of the image. Then run this Razor snippet (where 1234 is the id of your image):

dynamic image = new DynamicMedia(1234);

@image.AlternativeText

This returns "umbraco.MacroEngines.DynamicXml" as the type.

If the property is not empty and instead contains some text. The output is of course a string.

It also affects the XSLT output.

If you do a xsl:copy of the media node. you would expect the following

aa@bb.com

But instead you get something like this

aa@bb.com

''Originally created on CodePlex by [mikkeljohansen|http://www.codeplex.com/site/users/view/mikkeljohansen]'' on 6/14/2012 5:12:51 PM [Codeplex ID: 30847 - Codeplex Votes: 2]

Imported comments

''Comment by [mikkeljohansen|http://www.codeplex.com/site/users/view/mikkeljohansen] on 8/9/2012 11:55:24 PM:'' The bug is also in version 4.8

Comments

Mikkel Johansen 20 Nov 2012, 10:35:36

This seems to also happen in 4.10.1


Jeavon Leopold 20 Nov 2012, 12:04:55

Confirmed in 4.11.0 (changeset 5100489dbb47). In MVC using Typed and Dynamic it returns correctly as a empty string so this affects Razor Macros only.


Mikkel Johansen 20 Nov 2012, 12:28:34

It also affects the XSLT output.

If I do a xsl:copy of the media node. I would expect the following

aa@bb.com

But instead I get something like this

aa@bb.com


Mikkel Johansen 27 Mar 2013, 01:32:10

The problem is also in 6.0.1


Dan Evans 01 May 2013, 07:18:32

and 6.0.3


Jeroen Breuer 14 May 2013, 07:18:37

Could it be related to any of these issues? http://issues.umbraco.org/issue/U4-1636 - http://issues.umbraco.org/issue/U4-1405


Priority: Normal

Type: Bug

State: Open

Assignee:

Difficulty: Normal

Category:

Backwards Compatible: True

Fix Submitted:

Affected versions: 4.10.0, 4.11.0, 6.0.1

Due in version:

Sprint:

Story Points:

Cycle: