protected override bool TryGetThumbnailUrl(string fileUrl, out string thumbUrl) { try { thumbUrl = ThumbnailGenerator.Generate(fileUrl); return(!string.IsNullOrEmpty(thumbUrl)); } catch (Exception) { thumbUrl = ""; return(false); } }
private void MediaService_Saved(IMediaService sender, SaveEventArgs <IMedia> e) { foreach (var entity in e.SavedEntities) { if (entity.ContentType.Alias.Equals("folder", StringComparison.InvariantCultureIgnoreCase)) { continue; } if (!entity.HasProperty("umbracoFile")) { LogHelper.Debug <PdfThumbnailStartupHandler>($"Entity {entity.Id} have no umbracoFile"); continue; } try { var file = entity.GetValue <string>("umbracoFile"); if (string.IsNullOrEmpty(file)) { LogHelper.Warn <PdfThumbnailStartupHandler>($"File name is empty for entity {entity.Id}"); continue; } if (file.EndsWith(".pdf", StringComparison.InvariantCultureIgnoreCase)) { using ( ApplicationContext.Current.ProfilingLogger.TraceDuration <PdfThumbnailStartupHandler>( "Started Creating Thumbnail", "Completed Creating Thumbnail")) { ThumbnailGenerator.Generate(file); } } } catch (Exception exception) { LogHelper.Error <PdfThumbnailStartupHandler>("Error During Thumbnail", exception); } } }