Hello,
Thanks for the feedback!
I’m not sure about how the ACF Image Aspect Ratio Crop field works, but you can inject the attachments of your choice on any ACFE Form Email Action using the acfe/form/submit/email_args
hook. See documentation.
Just make sure that you correctly set the image file path. Usage example:
add_filter('acfe/form/submit/email_args/action=my-email', 'my_form_email_args', 10, 3);
function my_form_email_args($args, $form, $action){
// Add file to attachments
$args['attachments'] = array('/path/to/file.jpg');
// return
return $args;
}
If your files are inside a repeater, then you’ll have to retrieve them using the native have_rows(): the_row()
logic (See documentation), and inject them in the email arguments. Usage example:
add_filter('acfe/form/submit/email_args/action=my-email', 'my_form_email_args', 10, 3);
function my_form_email_args($args, $form, $action){
// initialize files
$files = array();
if(have_rows('my_repeater')):
while('my_repeater'): the_row();
// get image sub field
$my_image = get_sub_field('my_image');
// add my image to files
$files[] = $my_image;
endwhile;
endif;
// Add files to attachments
$args['attachments'] = $files;
// return
return $args;
}
Hope it helps!
Have a nice day!
Regards.
Thread Starter
jssbth
(@jssbth)
Thank you for the reply and the update.
I wanted to add that I don’t think the problem with dynamic attachments is unique to the way the 3rd party plugin works. The normal image field doesn’t work either. I believe it’s due to the field being inside a repeater field.
Edited to add: I know it may not be a priority, but it would great if this worked on repeaters too for us no/low code users.
-
This reply was modified 2 years, 6 months ago by jssbth.
Hello,
Absolutely, this feature was designed for top level fields and not sub fields in Repeater & Flexible Content since those would become virtually unlimited (possible sub field of a sub field of a sub field…). That would add a lot more complexity in the current system. It may come in the future, but for now this kind of complex setup require to use available hooks unfortunately.
Did you manage to make it work with the ACF Image Crop Field?
Regards.