Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
UserTemplates image saving too early #2630
When editing a UserTemplate on a page, a newly uploaded image immediately replaces the old image. When the user leaves the page without saving his changes, the old image doesn't get restored. This results in missing images and orphaned images in the Frontend Files directory
Steps to reproduce
Expected behavior / Proposed solutions
Save a replacement image to a temp directory first, and only replace the original image when the actual save button is pressed.
I currently don't have time for a pull request, but while I was implementing the UserTemplate parser in a custom module, this is what I came up with.
in the addCustomFieldInPlaceholderFor function of the js file
// In the saveCustomField function:
Add a file to the Ajax actions called SwitchFiles.php
Update the UploadFile.php this also fixes a bug that deletes a file when it has the same name as a file of another UserTemplate item: gives the files unique names.
Hope this helps!