Trying to get Ansel to work with Simple Cloner

Issue Details

My client really wants me to add the ability to clone an entry in ExpressionEngine. I’ve been working with Simple Cloner, and it’s almost working properly.

Unfortunately, I’ve run into an issue that is preventing Ansel and Simple Cloner from working together smoothly. I’ll admit right from the beginning that this is an obscure issue. But it’s a potential showstopper for this functionality, so I’m hoping that you and/or the Simple Cloner folks might help me figure this out. I pinged one of them on Slack, but he thought I should start with you. I’m happy to point them to this ticket if you need me to.

Here is what triggers this issue:

I have a channel with an Ansel field. I have a simple template that calls the image URL for the Ansel field. When I create an entry (EntryA) and add an image to the Ansel field, the template displays the URL properly. When I clone the entry in Simple Cloner (EntryA-Clone), the template displays the URL properly for both entries. But if I delete EntryA-Clone, the template breaks and generates a Fatal Error. The template remains broken until I open the EntryA, remove the image(s) from the Ansel field, save the entry, and then relink the image(s) within the Ansel field. Once I do that, the template again displays the image URL properly.

I’m using EE3.5.5, Ansel 2.0.3, and SimpleCloner 1.2.0. I’ve reproduced this issue on a clean install of 3.5.5 with only Ansel and Simple Cloner installed.

Any thoughts? Let me know if you have any other questions about my setup.

Discussion:

It sounds like Simple Cloner is duplicating the exp_ansel_images table rows but not creating the images themselves, but rather pointing back to the images Ansel created for the original field/entry.

The way Ansel works is that the original image is uploaded to the specified directory for source images, then that image is manipulated according to the field settings and crop lasso and saved as a new image. That image that Ansel manipulated and created is considered “owned” by the originating field. As such, if the image row is deleted, or the entry or owning element is deleted, the manipulated image is deleted. In the case of Simple Cloner (from what it sounds like it is doing), if it’s just duplicating the table rows in exp_ansel_images, then when you delete one of the image rows or entries, Ansel deletes the image because of the assumed ownership of the image. Thus that image goes missing for the other entry.

The last time I looked at Simple Cloner, it looked like it was doing a lot of procedural work, direct database calls and so forth. What would be ideal would be for Simple Cloner to prep the data that Ansel expects on entry submission, then run Ansel’s field type methods for the new entry. Failing that, Simple Cloner will need to duplicate the manipulated image for each image row in the containing element (entry), add it to the EE (or Assets or Treasury) file manager in the appropriate way, and then update the IDs in the duplicated exp_ansel_images table row to point to the new image.

TJ Draper April 12, 2017, 8:33 am

Log In or Register to Comment

Log In

Register

Email Address

Password

Note

Your account with the old support system does not carry over to the new support system. The new system is all tied together and connected with your account for purchasing and licenses. If you have a license, you have an account and you can log in with that email address and password. If you have not set a new password yet, you can do so with the forgot password link. Very sorry for any inconvenience.