Fix for using image field in subsite

Apr 27, 2011 at 8:21 AM

The image field does not work with subsite. The problem can be fixed with following steps:

1. For all files,

Replace

(SPPictureLibrary)SPContext.Current.Site.RootWeb.Lists[Properties.PictureLibraryName];

with

(SPPictureLibrary)SPContext.Current.Web.Lists[Properties.PictureLibraryName];

2. ChoosePicture.aspx.cs 

Replace

                        Page.Response.Write(string.Format(@"<script language='javascript'>
                   opener.document.getElementById('{0}').src = '{2}';
                           opener.document.getElementById('{0}').style.visibility = 'visible';
                                  opener.document.getElementById('{0}').style.width = '{3}px';
                                  opener.document.getElementById('{0}').style.height = '{4}px';
                                 opener.document.getElementById('{1}').value = '{2}'
                                 window.close();
                                </script>", Page.Request.QueryString["GUID"], Page.Request.QueryString["path"], list.ParentWeb.Site.Url + "/" + it.Url, dimensions.Width, dimensions.Height));

with

                   Page.Response.Write(string.Format(@"<script language='javascript'>
                   opener.document.getElementById('{0}').src = '{2}';
                           opener.document.getElementById('{0}').style.visibility = 'visible';
                                  opener.document.getElementById('{0}').style.width = '{3}px';
                                  opener.document.getElementById('{0}').style.height = '{4}px';
                                 opener.document.getElementById('{1}').value = '{2}'
                                 window.close();
                                </script>", Page.Request.QueryString["GUID"], Page.Request.QueryString["path"], it.ServerRelativeUrl, dimensions.Width, dimensions.Height));

3. Rebuild the wsp file