mirror of
https://github.com/revenz/FileFlowsPlugins.git
synced 2026-04-29 06:09:53 -05:00
FF-2048: Set thumbnail element
This commit is contained in:
@@ -0,0 +1,43 @@
|
||||
using FileFlows.Plugin;
|
||||
using FileFlows.Plugin.Attributes;
|
||||
|
||||
namespace FileFlows.BasicNodes.Functions;
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Flow element that sets the thumbnail of a file in FileFlows
|
||||
/// </summary>
|
||||
public class SetFileFlowsThumbnail: Node
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public override int Inputs => 1;
|
||||
/// <inheritdoc />
|
||||
public override int Outputs => 1;
|
||||
/// <inheritdoc />
|
||||
public override string Icon => "fas fa-image";
|
||||
/// <inheritdoc />
|
||||
public override FlowElementType Type => FlowElementType.Process;
|
||||
/// <inheritdoc />
|
||||
public override string HelpUrl => "https://fileflows.com/docs/plugins/basic-nodes/set-fileflows-thumbnail";
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the name of the file of the thumbnail
|
||||
/// </summary>
|
||||
[TextVariable(1)]
|
||||
public string FilePath { get; set; }
|
||||
|
||||
/// <inheritdoc />
|
||||
public override int Execute(NodeParameters args)
|
||||
{
|
||||
string file = args.ReplaceVariables(FilePath ?? string.Empty, true)?.EmptyAsNull() ?? args.WorkingFile;
|
||||
if(string.IsNullOrWhiteSpace(file))
|
||||
return args.Fail("File Path not set");
|
||||
var localResult = args.FileService.GetLocalPath(file);
|
||||
if(localResult.Failed(out var error))
|
||||
return args.Fail("Failed to get local path: " + error);
|
||||
var local = localResult.Value;
|
||||
args.SetThumbnail(file);
|
||||
args.Logger.ILog("Thumbnail set");
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user