public HTML5ImagePickerEntity GetEntity(HTML5ImageDataSet.HTML5ImagesRow dr)
        {
            // No datarow provided
            if (dr == null)
            {
                return(null);
            }

            // Create new picker
            HTML5ImagePickerEntity entity = new HTML5ImagePickerEntity();

            entity.Key         = dr.Src;
            entity.DisplayText = dr.Src;
            entity.Alt         = dr.Alt;
            entity.Src         = dr.Src;
            entity.Height      = dr.Height;
            entity.Width       = dr.Width;
            entity.Description = dr.Alt;
            entity.Web         = dr.Web;
            entity.List        = dr.List;
            entity.Preview     = dr.Preview;
            entity.IsResolved  = true;
            entity.ItemId      = dr.ImageId;

            return(entity);
        }
        private void GetImagesForWeb(Guid guid, string search, string groupname)
        {
            if (site == null)
            {
                site = SPContext.Current.Site;
            }

            SPWeb web = site.RootWeb;

            if (guid != Guid.Empty)
            {
                web = site.OpenWeb(guid);
            }
            bool rootweb = web.IsRootWeb;

            foreach (SPList list in web.Lists)
            {
                if (list.IsSiteAssetsLibrary || ContainsPictureTypes(list))
                {
                    SPField searchField        = list.Fields[new Guid(groupname)];
                    SPListItemCollection items = null;

                    if (!string.IsNullOrEmpty(search))
                    {
                        SPQuery query = new SPQuery();

                        string valueType = searchField.TypeAsString;
                        if (searchField.Type == SPFieldType.Calculated)
                        {
                            valueType = "Text";
                        }

                        query.ViewAttributes = "Scope=\"Recursive\"";
                        query.Query          = string.Format("<Where><{0}><FieldRef ID=\"{1}\"/><Value Type=\"{2}\">{3}</Value></{0}></Where>"
                                                             , searchOperator ?? "Contains"
                                                             , searchField.Id.ToString()
                                                             , valueType
                                                             , search);

                        items = list.GetItems(query);

                        //Select the images based upon search.
                        foreach (SPListItem item in items)
                        {
                            if (!dataset.HTML5Images.Rows.Contains(item.UniqueId))
                            {
                                HTML5ImageDataSet.HTML5ImagesRow row = dataset.HTML5Images.NewHTML5ImagesRow();
                                row.ImageId = item.UniqueId;
                                row.Name    = item.Name;

                                row.Preview  = Convert.ToString(item["ows_EncodedAbsThumbnailUrl"]);
                                row.Keywords = Convert.ToString(item["ows_Keywords"]);
                                row.Width    = Convert.ToInt32(item["ows_ImageWidth"]);
                                row.Height   = Convert.ToInt32(item["ows_ImageHeight"]);
                                row.Alt      = Convert.ToString(item["ows_Description"]);
                                row.Web      = item.Web.Title;
                                row.List     = item.ParentList.Title;

                                if (rootweb)
                                {
                                    row.Src = "/" + item.File.Url;
                                }
                                else
                                {
                                    row.Src = "/" + item.Web.ServerRelativeUrl + "/" + item.File.Url;
                                }

                                dataset.HTML5Images.AddHTML5ImagesRow(row);
                                row.AcceptChanges();
                            }
                        }
                    }
                }
            }

            if (!web.IsRootWeb)
            {
                GetImagesForWeb(web.ParentWeb.ID, search, groupname);
            }
        }
        protected void RenderRowColumn(HTML5ImageDataSet.HTML5ImagesRow row, int iColumn, Control parent)
        {
            string    str   = string.Empty;
            TableCell child = new TableCell
            {
                CssClass = "ms-pb"
            };

            child.Attributes.Add("nowrap", "true");
            child.Attributes.Add("UNSELECTABLE", "on");
            child.Width = new Unit(10);
            Literal literal = new Literal();

            //image
            if ((iColumn == 0))
            {
                string str2 = "false";
                str  = "<a class=\"thumbnail\" href='javascript:' onfocus='PickerResultsNameOnFocus(this, event, " + str2 + " );' onkeydown='PickerResultsNameOnKeyDown(this, event," + str2 + ");' onclick='" + this.selectOnName + "' id='resultTable_" + parent.ID + "_Link'>";
                str += "<img width=\"48\" height=\"48\" border='0' src=\"" + row.Preview + "\" alt=\"" + row.Alt + "\"/>";
                str += "<span><img src=\"" + row.Src + "\" alt=\"" + row.Alt + "\"/></span>";
                str += "</a>";
            }

            //Name
            if ((iColumn == 1))
            {
                str = row.Name;
            }

            //Dimension
            if ((iColumn == 2))
            {
                str = row.Height.ToString() + " x " + row.Width.ToString();
            }

            //Alt
            if ((iColumn == 3))
            {
                str = row.Alt;
            }

            //Keywords
            if ((iColumn == 4))
            {
                str = row.Keywords;
            }

            //Web
            if ((iColumn == 5))
            {
                str = row.Web;
            }

            //List
            if ((iColumn == 6))
            {
                str = row.List;
            }

            literal.Text = str;
            child.Controls.Add(literal);
            parent.Controls.Add(child);
        }