From 97355bde6f7b34dc83f2e004732f00f51f3d727a Mon Sep 17 00:00:00 2001 From: Sebastiaan Janssen Date: Thu, 11 Apr 2013 13:15:08 -0200 Subject: [PATCH] Fixes U4-2091 Inserting image in RTE with mediatype "File" causes YSOD --- .../tinyMCE3/webcontrol/TinyMCEWebControl.cs | 29 ++++++++++++++----- 1 file changed, 22 insertions(+), 7 deletions(-) diff --git a/src/umbraco.editorControls/tinyMCE3/webcontrol/TinyMCEWebControl.cs b/src/umbraco.editorControls/tinyMCE3/webcontrol/TinyMCEWebControl.cs index 25ba1d1b3d..e3322d483d 100644 --- a/src/umbraco.editorControls/tinyMCE3/webcontrol/TinyMCEWebControl.cs +++ b/src/umbraco.editorControls/tinyMCE3/webcontrol/TinyMCEWebControl.cs @@ -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);