Fixes 28407

[TFS Changeset #75946]
This commit is contained in:
hartvig
2010-08-20 09:09:19 +00:00
parent df01d4842b
commit 34f9d84e5e
2 changed files with 34 additions and 28 deletions

View File

@@ -14,6 +14,7 @@ using System.Web.UI.HtmlControls;
using System.Resources;
using umbraco.editorControls.mediapicker;
using umbraco.uicontrols.TreePicker;
using umbraco.cms.businesslogic;
namespace umbraco.editorControls
{
/// <summary>
@@ -148,7 +149,7 @@ namespace umbraco.editorControls
if (_showpreview)
{
if (string.IsNullOrEmpty(ItemIdValue.Value))
if (string.IsNullOrEmpty(ItemIdValue.Value) || !CMSNode.IsNode(int.Parse(ItemIdValue.Value)))
{
PreviewContainer.Style.Add(HtmlTextWriterStyle.Display, "none");
ImgViewer.MediaId = -1;

View File

@@ -5,6 +5,7 @@ using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using umbraco.cms.businesslogic.media;
using umbraco.cms.businesslogic;
namespace umbraco.controls.Images
{
@@ -77,40 +78,44 @@ namespace umbraco.controls.Images
}
private void LookupData()
{
if (MediaId > 0)
{
Media m = new Media(MediaId);
{
if (MediaId > 0 && Media.IsNode(MediaId))
{
Media m = new Media(MediaId);
// TODO: Remove "Magic strings" from code.
var pFile = m.getProperty("fileName");
if (pFile == null) pFile = m.getProperty("umbracoFile");
if (pFile == null) pFile = m.getProperty("file");
if (pFile == null)
{
//the media requested does not correspond with the standard umbraco properties
return;
}
// TODO: Remove "Magic strings" from code.
var pFile = m.getProperty("fileName");
if (pFile == null) pFile = m.getProperty("umbracoFile");
if (pFile == null) pFile = m.getProperty("file");
if (pFile == null)
{
//the media requested does not correspond with the standard umbraco properties
return;
}
MediaItemPath = pFile.Value != null && !string.IsNullOrEmpty(pFile.Value.ToString())
? umbraco.IO.IOHelper.ResolveUrl(pFile.Value.ToString())
MediaItemPath = pFile.Value != null && !string.IsNullOrEmpty(pFile.Value.ToString())
? umbraco.IO.IOHelper.ResolveUrl(pFile.Value.ToString())
: "#";
AltText = MediaItemPath != "#" ? m.Text : ui.GetText("no") + " " + ui.GetText("media");
AltText = MediaItemPath != "#" ? m.Text : ui.GetText("no") + " " + ui.GetText("media");
var pWidth = m.getProperty("umbracoWidth");
var pHeight = m.getProperty("umbracoHeight");
var pWidth = m.getProperty("umbracoWidth");
var pHeight = m.getProperty("umbracoHeight");
if (pWidth != null && pWidth.Value != null && pHeight != null && pHeight.Value != null)
{
int.TryParse(pWidth.Value.ToString(), out m_FileWidth);
int.TryParse(pHeight.Value.ToString(), out m_FileHeight);
}
if (pWidth != null && pWidth.Value != null && pHeight != null && pHeight.Value != null)
{
int.TryParse(pWidth.Value.ToString(), out m_FileWidth);
int.TryParse(pHeight.Value.ToString(), out m_FileHeight);
}
string ext = MediaItemPath.Substring(MediaItemPath.LastIndexOf(".") + 1, MediaItemPath.Length - MediaItemPath.LastIndexOf(".") - 1);
MediaItemThumbnailPath = MediaItemPath.Replace("." + ext, "_thumb.jpg");
string ext = MediaItemPath.Substring(MediaItemPath.LastIndexOf(".") + 1, MediaItemPath.Length - MediaItemPath.LastIndexOf(".") - 1);
MediaItemThumbnailPath = MediaItemPath.Replace("." + ext, "_thumb.jpg");
ImageFound = true;
}
ImageFound = true;
}
else
{
ImageFound = false;
}
}
}
}