I mean copying the images or documents from my current site to the new install. My current site contains rich text editors that insert images and link to documents from the media section. The content (text) uMirror handles fine, but obviously the documents and media that are linked to from within those RTEs is not being copied over, resulting in broken links. This is to be expected, but I'm not sure how to properly solve it.
Hi Dan and sorry for my late answer. All this stuff has to be done into a proxy method, I give you a example:
In this case, we keep the media folder structure between both Umbraco instances.
First, you can match all your RTE media dependency within the proxy method this way:
foreach (Match index in Regex.Matches(your-legacy-umbraco.config, "[\"]/media/(.+?)[\"]", RegexOptions.IgnoreCase)) { AutoFillMedia(index.Value.Replace("\"", ""), ref your-legacy-umbraco.config); }
The AutoFillMedia method create a new Media and change its path within the your-legacy-umbraco.config
private static void AutoFillMedia(String mSrcLegacy, ref String umbracoconfig)
{
if (File.Exists(HttpContext.Current.Server.MapPath("path to your legacy's media files" + mSrcLegacy)))
{
var mFolderPath = GetMediaPathBySrc(mSrcLegacy);
var mFilePath = HttpContext.Current.Server.MapPath("path to your legacy's media files" + mSrcLegacy);
var mParentId = Lecoati.uMirror.Core.Util.GetMediaParentId(mFolderPath);
var mNewId = Lecoati.uMirror.Core.Util.SaveMedia(mFilePath, mParentId);
var mNew = ApplicationContext.Current.Services.MediaService.GetById(mNewId);
if (mNew != null && mNew.HasProperty("umbracoFile"))
umbracoconfig = umbracoconfig.Replace(mSrcLegacy, mNew.GetValue("umbracoFile").ToString());
}
}
We added some helper methods within uMirror core to make some Media manipulation:
GetMediaParentId: look for a specific media folder by path (ex: /home/banner ), if the path doen't existe, it creates it
SaveMedia: save the media file
The Method GetMediaPathBySrc looks for the legacy media path:
private static string GetMediaPathBySrc(string mediaPath)
{
string url = "Rest service from the legacy website which return the media path";
using (WebClient client = new WebClient())
{
return client.DownloadString(string.Format(url, mediaPath));
}
}
The Rest service from the legacy structure is quite easy to implement, let me know if you have any question about it, I can look after this specific method.
Handling Media within RTE
How do you handle the migration of media that are referenced within a RTE?
Hi Dan,
What do you mean migration ?
Removing it from media section ?
Thanks
I mean copying the images or documents from my current site to the new install. My current site contains rich text editors that insert images and link to documents from the media section. The content (text) uMirror handles fine, but obviously the documents and media that are linked to from within those RTEs is not being copied over, resulting in broken links. This is to be expected, but I'm not sure how to properly solve it.
Hi Dan and sorry for my late answer. All this stuff has to be done into a proxy method, I give you a example:
In this case, we keep the media folder structure between both Umbraco instances.
First, you can match all your RTE media dependency within the proxy method this way:
The AutoFillMedia method create a new Media and change its path within the your-legacy-umbraco.config
We added some helper methods within uMirror core to make some Media manipulation:
The Method GetMediaPathBySrc looks for the legacy media path:
The Rest service from the legacy structure is quite easy to implement, let me know if you have any question about it, I can look after this specific method.
is working on a reply...