2
Vote

Media_AfterSave Error When Media Type has no "umbracoFile" alias

description

We keep HTML banners in the Media section of Umbraco and we created a Media Type with no "umbracoFile" property.
 
Suggested Fix:
 
public static void Media_AfterSave(Media sender, umbraco.cms.businesslogic.SaveEventArgs e)
{
if (sender.getProperty("umbracoFile") != null)
{
    // after a file is removed
    if (string.IsNullOrEmpty(sender.getProperty("umbracoFile").Value.ToString()))
    {
        // remove node from index
        Indexer.RemoveNode(sender.Id);
    }
    // after a file is uploaded
    else
    {
        // add node to index
        Indexer.Index(sender);
    }
}
}

comments