Image in mediadatabase

        private string Getimage(string imagenaam)
        {
            string imagestring = string.Empty;
            System.Text.StringBuilder sb = new System.Text.StringBuilder();
            imagenaam = imagenaam + " jpg";
            ////Database db = Sitecore.Context.Database;
            Sitecore.Data.Database db = Sitecore.Configuration.Factory.GetDatabase("master");
            string mq = "/sitecore/media library/Pfotos/" + imagenaam;
            if (!string.IsNullOrEmpty(mq))
            {
                try
                {
                    Sitecore.Data.Items.MediaItem mijnMediaItem = db.SelectSingleItem(mq);
                    if (mijnMediaItem != null)
                    {
                        sb.Append(" <image showineditor='1' mediaid='");
                        sb.Append(mijnMediaItem.ID.ToString());
                        sb.Append("' mediapath='/Pfotos/");
                        sb.Append(imagenaam);
                        sb.Append("' src='~/media/Pfotos/");
                        sb.Append(imagenaam);
                        sb.Append(".ashx' alt='' />");
                        imagestring = sb.ToString();
                    }
                }
                catch (System.Exception)
                {
                    //eFocusIntranet.LogUtil.Error("image niet gevonden in sitecore:" + mq);
                }
            }

            return imagestring;
        }

{{opmerking.Naam}}:

{{opmerking.OpmerkingText}}

            

Saving your comment....

Naam is verplicht!
Email is verplicht!
Opmerking is verplicht!