Created
February 5, 2020 13:34
-
-
Save spivurno/04b3927dc6dc0b57bca52505b7f08fbb to your computer and use it in GitHub Desktop.
Gravity Perks // Populate Anything // Populate Multi-file Upload Images as Separate Choices
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Gravity Perks // Populate Anything // Populate Multi-file Upload Images as Separate Choices | |
* http://gravitywiz.com/documentation/gravity-forms-populate-anything/ | |
*/ | |
// Update "123" to your form ID; update "4" to the ID the field you're populating via Populate Anything. | |
add_filter( 'gppa_input_choices_123_4', function( $choices, $field, $objects ) { | |
$parsed_choices = array(); | |
foreach( $choices as $choice ) { | |
$_choices = explode( ', ', $choice['value'] ); | |
foreach( $_choices as $_choice ) { | |
$parsed_choices[] = array( | |
'value' => $_choice, | |
'text' => sprintf( '<img src="%s" width="200">', $_choice ), | |
); | |
} | |
} | |
return $parsed_choices; | |
}, 10, 3 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
👉 This Gist has been migrated to the Gravity Wiz Snippet Library:
https://github.com/gravitywiz/snippet-library/blob/master/gp-populate-anything/gppa-populate-multi-file-upload-as-separate-choices.php