/// <summary> /// Ommitted for now - we actually need to make an authenticated http POST to get each resource. /// Will do this shortly. More info http://dev.evernote.com/start/core/resources.php /// </summary> /// <param name="note"></param> /// <param name="html"></param> void ResolveMedia(Note note, HtmlAgilityPack.HtmlDocument html) { // TODO: We are removing these just now but we really want to download and locally store them via http POST RemoveMedia(html); return; if (note == null) { return; } //<en-media alt="Penultimate" type="image/png" hash="bb54c12582d7d1793fb860ae27fe9daa"></en-media> var els = html.DocumentNode.SelectNodes("//en-media"); if (els != null) { foreach (var element in els) { // try to load in the image given the hash Resource img = _Instance.getResourceByHash(_authToken, note.Guid, System.Text.Encoding.Unicode.GetBytes(element.GetAttributeValue("hash", String.Empty)), true, false, false); // make sure we got something back and it has a url if (img == null || img.Attributes == null || !String.IsNullOrWhiteSpace(img.Attributes.SourceURL)) { return; } // get the url string url = img.Attributes.SourceURL; #region convert image to a local image /* * System.Drawing.ImageConverter converter = new System.Drawing.ImageConverter(); * System.Drawing.Image imgres = (System.Drawing.Image)converter.ConvertTo(img.Data.Body, typeof(System.Drawing.Image)); * * // If we want to put the image in we need to somehow convert the image to base 64 encoding as we are not referencing the url explicitly */ #endregion // set the image url HtmlAgilityPack.HtmlNode replacementImage = new HtmlAgilityPack.HtmlNode(HtmlAgilityPack.HtmlNodeType.Element, element.OwnerDocument, 0); replacementImage.Attributes.Add("src", url); // we can now replace the original media tag with the new one element.ParentNode.ReplaceChild(replacementImage, element); } } }