Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save spivurno/04b3927dc6dc0b57bca52505b7f08fbb to your computer and use it in GitHub Desktop.
Save spivurno/04b3927dc6dc0b57bca52505b7f08fbb to your computer and use it in GitHub Desktop.
Gravity Perks // Populate Anything // Populate Multi-file Upload Images as Separate Choices
<?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