Check if media upload is new or overwriting existing
I have an aftersave handler in my media section that needs to be triggered only the first time an file gets uploaded. If someone opens up the media item and uploads a new file to the existing media item, then I don't want to execute the aftersave event.
Well I've introduced a solution that is unfortunately very hacky, couldn't use BeforeSave or AfterNew at all because it's eiter too early or too late. Media items are also not versioned, so VersionDate vs CreateDate was useless.
So I introduced a new property "preventAfterSaveAction" and I'm setting it immediately in my AfterSave handler:
if (sender.ContentType.Alias != "Image") return;
if (sender.getProperty("preventAfterSaveAction").Value.ToString() == "1") return;
sender.getProperty("preventAfterSaveAction").Value = "1";
I hate that i have to use an extra property for this though.
Check if media upload is new or overwriting existing
I have an aftersave handler in my media section that needs to be triggered only the first time an file gets uploaded. If someone opens up the media item and uploads a new file to the existing media item, then I don't want to execute the aftersave event.
Is there a good way to detect this?
Well I've introduced a solution that is unfortunately very hacky, couldn't use BeforeSave or AfterNew at all because it's eiter too early or too late. Media items are also not versioned, so VersionDate vs CreateDate was useless.
So I introduced a new property "preventAfterSaveAction" and I'm setting it immediately in my AfterSave handler:
I hate that i have to use an extra property for this though.
is working on a reply...