Has anyone experienced an empty properties list for a DynamicMedia instance when being used on a macro script? The instance has a valid ID and is being created from the following method call:
var mediaItem = @Library.MediaById(n.ImagePropertyAlias);
When trying to access some of the instance's properties, null values are returned. For example, the following wouldn't return anything even though the property value is correct when looking via Umbraco's backend:
mediaItem.umbracoFile
While debugging the application, I can see from watching the instance that the PropertiesAsList collection is empty. When running the Umbraco instance on another server, for example my local development machine, the collection contains all properties specified for that media type.
As I only get this on one server, it makes me think that the issue is environment specific. I've tried copying all configuration files to test locally but the issue doesn't occur. I'm currently using Umbraco v4.11.1.
Hey Dan, I think you might be the victim of some properties not being added to the Examine index properly (this is what DynamicMedia is using to get it's data). Maybe a re-index will help.
You can check with some legacy methods to see if, for example, the width actually is being returned:
@{ var media = new umbraco.cms.businesslogic.media.Media(n.ImagePropertyAlias); var file = media.getProperty("umbracoWidth");
string width = file.Value.ToString();
}
<p>Width: @width</p>
If that works then the Examine index is definitely out of date. I remember fixes being done for that recently (but can't find them right now). In any case I would recommend you upgrade to 4.11.5 and run the path fixup tool to prevent problems after moving content/media, read more about those here: http://umbraco.com/follow-us/blog-archive/2013/2/1/umbraco-4114-released.aspx
Hey Sebastiaan. Thanks for your reply. I tried your suggestion and confirmed the correct properties did actually exist. As a quick fix, I went through any media item which wouldn't display and saved the item through Umbraco. I presume this helped with rebuilding that media item's properties within Umbraco's Examine Indexes. My next step will be to try upgrading to v4.11.5.
Yep, saving it triggers the examine index event. You'll still need to rebuild the index for the rest of the items, but at least you now have the source of your problem! :)
Empty Properties List for a DynamicMedia instance
Has anyone experienced an empty properties list for a DynamicMedia instance when being used on a macro script? The instance has a valid ID and is being created from the following method call:
var mediaItem = @Library.MediaById(n.ImagePropertyAlias);
When trying to access some of the instance's properties, null values are returned. For example, the following wouldn't return anything even though the property value is correct when looking via Umbraco's backend:
While debugging the application, I can see from watching the instance that the PropertiesAsList collection is empty. When running the Umbraco instance on another server, for example my local development machine, the collection contains all properties specified for that media type.
As I only get this on one server, it makes me think that the issue is environment specific. I've tried copying all configuration files to test locally but the issue doesn't occur. I'm currently using Umbraco v4.11.1.
Thanks,
Dan.
Hey Dan, I think you might be the victim of some properties not being added to the Examine index properly (this is what DynamicMedia is using to get it's data). Maybe a re-index will help.
You can check with some legacy methods to see if, for example, the width actually is being returned:
If that works then the Examine index is definitely out of date. I remember fixes being done for that recently (but can't find them right now). In any case I would recommend you upgrade to 4.11.5 and run the path fixup tool to prevent problems after moving content/media, read more about those here: http://umbraco.com/follow-us/blog-archive/2013/2/1/umbraco-4114-released.aspx
Also, I recommend the Umbraco Examine Dashboard package to do re-indexing more easily: http://our.umbraco.org/projects/developer-tools/examine-dashboard
Hey Sebastiaan. Thanks for your reply. I tried your suggestion and confirmed the correct properties did actually exist. As a quick fix, I went through any media item which wouldn't display and saved the item through Umbraco. I presume this helped with rebuilding that media item's properties within Umbraco's Examine Indexes. My next step will be to try upgrading to v4.11.5.
Thanks,
Dan.
Good to hear!
Yep, saving it triggers the examine index event.
You'll still need to rebuild the index for the rest of the items, but at least you now have the source of your problem! :)
is working on a reply...