Having issues when we deploy a site including media client may have loaded in prior to deploy.
It appears the published cache gets out of sync so I'm wondering how we force it to clear and refresh rather than going through each media node and hitting save.
public static void SaveMedia()
{
try
{
string sql = @"
select un.id
from umbracoNode un
where un.nodeObjectType = @type";
//Get all the media items.
using (IRecordsReader dr = SqlHelper.ExecuteReader(sql, SqlHelper.CreateParameter("@type", Media._objectType)))
{
//Loop trough all the media items.
while (dr.Read())
{
//Get the id of a media item.
int mediaId = dr.GetInt("id");
//Resave media
Media media = new Media(mediaId);
media.Save();
media.XmlGenerate(new XmlDocument());
}
}
}
catch (Exception ex)
{
}
}
Force Published Cache Refresh For Media
Hi All,
Having issues when we deploy a site including media client may have loaded in prior to deploy.
It appears the published cache gets out of sync so I'm wondering how we force it to clear and refresh rather than going through each media node and hitting save.
You could use this code (old API example) to save all the media.
Jeroen
is working on a reply...