Copied to clipboard

Flag this post as spam?

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


  • Dan Lister 416 posts 1974 karma points c-trib
    Mar 05, 2013 @ 16:18
    Dan Lister
    0

    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:

    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.

    Thanks,
    Dan.

  • Sebastiaan Janssen 5060 posts 15522 karma points MVP admin hq
    Mar 05, 2013 @ 16:35
    Sebastiaan Janssen
    100

    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

  • Sebastiaan Janssen 5060 posts 15522 karma points MVP admin hq
    Mar 05, 2013 @ 16:36
    Sebastiaan Janssen
    0

    Also, I recommend the Umbraco Examine Dashboard package to do re-indexing more easily: http://our.umbraco.org/projects/developer-tools/examine-dashboard

  • Dan Lister 416 posts 1974 karma points c-trib
    Mar 05, 2013 @ 17:22
    Dan Lister
    0

    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. 

  • Sebastiaan Janssen 5060 posts 15522 karma points MVP admin hq
    Mar 05, 2013 @ 17:33
    Sebastiaan Janssen
    0

    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! :)

Please Sign in or register to post replies

Write your reply to:

Draft