Displaying images instead of array items
-
Hi Roland,
Thank you for the great plugin.
I’ve been trying to display images instead of strings in a list (a dropdown that was filled by user). Last time you said I have to usepdb-before_display_form_element
.
I read the docs and checked “Creating Custom Form Elements” example you’ve created in the documentation but I couldn’t customize it to my need.
I coded the following but I don’t get the result I need. Where am I going wrong?add_filter('pdb-before_display_form_element','my_function', 10, 2); /** * @param array $fields * @return array */ function my_function( $value, $field ) { if (in_array('certificate name 1', $field->certificates)) { $value = '<img src="path to cert logo 1" alt="">'; } else if (in_array('certificate name 2', $field->certificates)) { $value = '<img src="path to cert logo 2" alt="">'; } else { $value = '<img src="path to non-existing logo" alt="">'; } return $value; }
Viewing 3 replies - 1 through 3 (of 3 total)
Viewing 3 replies - 1 through 3 (of 3 total)
- The topic ‘Displaying images instead of array items’ is closed to new replies.