Bloom.Book.BookData.UpdateImageFromDataSet C# (CSharp) Method

UpdateImageFromDataSet() private method

Given a node in the content section of the book that has a data-book attribute, see if this node holds an image and if so, look up the url of the image from the supplied dataset and stick it in there. Handle both img elements and divs that have a background-image in an inline style attribute. At the time of this writing, the only image that is handled here is the cover page. The URLs of images in the content of the book are not known to the data-div. But each time the book is loaded up, we collect up data from the xmatter and stick it in the data-div(in the DOM) / dataSet (in an object here in code), stick in a blank xmatter, then push the values back into the xmatter.
private UpdateImageFromDataSet ( DataSet data, XmlElement node, string key ) : bool
data DataSet
node System.Xml.XmlElement
key string
return bool
        private bool UpdateImageFromDataSet(DataSet data, XmlElement node, string key)
        {
            if (!HtmlDom.IsImgOrSomethingWithBackgroundImage(node))
                return false;

            var newImageUrl = UrlPathString.CreateFromUrlEncodedString(data.TextVariables[key].TextAlternatives.GetFirstAlternative());
            var oldImageUrl = HtmlDom.GetImageElementUrl(node);
            var imgOrDivWithBackgroundImage = new ElementProxy(node);
            HtmlDom.SetImageElementUrl(imgOrDivWithBackgroundImage,newImageUrl);

            if (!newImageUrl.Equals(oldImageUrl))
            {
                Guard.AgainstNull(_updateImgNode, "_updateImgNode");

                try
                {
                    _updateImgNode(node);
                }
                catch (TagLib.CorruptFileException e)
                {
                    NonFatalProblem.Report(ModalIf.Beta, PassiveIf.All, "Problem reading image metadata", newImageUrl.NotEncoded, e);
                    return false;
                }
            }
            return true;
        }