private void CopyImages(HtmlDom pageDom)
{
// Manifest has to include all referenced files
foreach (XmlElement img in HtmlDom.SelectChildImgAndBackgroundImageElements(pageDom.RawDom.DocumentElement))
{
var url = HtmlDom.GetImageElementUrl(img);
if (url == null || url.NotEncoded=="")
continue; // very weird, but all we can do is ignore it.
// Notice that we use only the path part of the url. For some unknown reason, some bloom books
// (e.g., El Nino in the library) have a query in some image sources, and at least some ePUB readers
// can't cope with it.
var filename = url.PathOnly.NotEncoded;
if (string.IsNullOrEmpty(filename))
continue;
// Images are always directly in the folder
var srcPath = Path.Combine(Book.FolderPath, filename);
if (RobustFile.Exists(srcPath))
CopyFileToEpub(srcPath);
else
img.ParentNode.RemoveChild(img);
}
}