public void RegisterWithServer(EnhancedImageServer server)
{
server.RegisterEndpointHandler(kBrandingImageUrlPart, request =>
{
#if DEBUG
// The book templates are allowed to use the branding api. All real books
// should not use this facility.
if (request.CurrentBook == null || request.CurrentBook.FolderPath == null ||
!Book.BookStorage.IsStaticContent(request.CurrentBook.FolderPath))
{
//Debug.Fail("Books should no longer have branding api urls");
}
#endif
var fileName = request.RequiredFileNameOrPath("id");
var path = FindBrandingImageFileIfPossible(_collectionSettings.BrandingProjectKey, fileName.NotEncoded, request.CurrentBook.GetLayout());
// And this is perfectly normal, to not have a branding image at all, for a particular page:
if (string.IsNullOrEmpty(path))
{
request.Failed("");
// the HTML will need to be able to handle this invisibly... see http://stackoverflow.com/questions/22051573/how-to-hide-image-broken-icon-using-only-css-html-without-js
return;
}
request.ReplyWithImage(path);
}, false);
}