Fixes U4-2091 Inserting image in RTE with mediatype "File" causes YSOD

This commit is contained in:
Sebastiaan Janssen
2013-04-11 13:15:08 -02:00
parent ed35f234de
commit 97355bde6f

View File

@@ -338,15 +338,30 @@ namespace umbraco.editorControls.tinyMCE3.webcontrol
var heightProperty = imageMedia.Properties.FirstOrDefault(x => x.Alias == "umbracoHeight");
var umbracoFileProperty = imageMedia.Properties.FirstOrDefault(x => x.Alias == "umbracoFile");
// Format the tag
if (widthProperty != null && heightProperty != null && umbracoFileProperty != null)
var widthValue = string.Empty;
try
{
tempTag = string.Format("{0} rel=\"{1},{2}\" src=\"{3}\" />",
tempTag,
widthProperty.Value,
heightProperty.Value,
umbracoFileProperty.Value);
widthValue = widthProperty.Value.ToString();
}
catch (Exception wx)
{
// For some reason widthProperty == null returns false when the widthproperty is actually null...
}
var heightValue = string.Empty;
try
{
heightValue = heightProperty.Value.ToString();
}
catch (Exception ex)
{
// For some reason heightProperty == null returns false when the heightProperty is actually null...
}
// Format the tag
if (umbracoFileProperty != null)
tempTag = string.Format("{0} rel=\"{1},{2}\" src=\"{3}\" />", tempTag, widthValue, heightValue, umbracoFileProperty.Value);
}
html = html.Replace(tag.Value, tempTag);