# Dynamically Populating Drop Down

**URL:** https://community.gravityforms.com/t/dynamically-populating-drop-down/13875
**Category:** Get Help
**Tags:** dynamic-population
**Created:** [November 15, 2022, 3:29pm UTC](https://community.gravityforms.com/t/dynamically-populating-drop-down/13875 "2022-11-15T15:29:02Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![user561](https://avatars.discourse-cdn.com/v4/letter/u/e47c2d/32.png) [@user561](https://community.gravityforms.com/u/user561)
#### Post date: [November 15, 2022, 3:29pm UTC](https://community.gravityforms.com/t/dynamically-populating-drop-down/13875/1 "2022-11-15T15:29:02Z")

</div>

I am using Gravity Forms to dynamically populate the values in a select with custom post types titles using the code [found here](https://docs.gravityforms.com/dynamically-populating-drop-down-or-radio-buttons-fields/). I am trying to add the featured image to the option tag, after the title:

```auto
add_filter( 'gform_pre_render_12', 'populate_posts' );
add_filter( 'gform_pre_validation_12', 'populate_posts' );
add_filter( 'gform_pre_submission_filter_12', 'populate_posts' );
add_filter( 'gform_admin_pre_render_12', 'populate_posts' );
function populate_posts( $form ) {
 
    foreach ( $form['fields'] as &$field ) {
 
        if ( $field->type != 'select' || strpos( $field->cssClass, 'cpt-name' ) === false ) {
            continue;
        }
 
        $posts = get_posts( 'post_type=agent-name&numberposts=-1&post_status=publish&orderby=name&order=ASC' );
 
        $choices = array();
 
        foreach ( $posts as $post ) {

            $featured_image = get_the_post_thumbnail($post->ID, 'thumbnail');

            $choices[] = array( 
                'text' => $post->post_title . $featured_image, 
                'value' => $post->post_title 
            );
        }
 
        // update 'Select a Post' to whatever you'd like the instructive option to be
        $field->placeholder = 'Select a Post';
        $field->choices = $choices;
 
    }
 
    return $form;
}

```

I tried to add the featured image it after the option text but it’s printing `&lt;img&gt;` instead of `<img>`. Even so, when I edit this in the code inspector to add the correct img tag, it still does not appear.

Is it possible to add the featured image to an option tag?

---

<div class="post-metadata">

### Author: ![david](https://sea2.discourse-cdn.com/flex020/user_avatar/community.gravityforms.com/david/32/2517_2.png) [@david](https://community.gravityforms.com/u/david)
#### Post date: [November 16, 2022, 2:32pm UTC](https://community.gravityforms.com/t/dynamically-populating-drop-down/13875/2 "2022-11-16T14:32:28Z")

</div>

Hey Marc, including images in \<option\> tags is not supported ([quick demo](https://jsfiddle.net/gf91hper/)). It doesn’t look like [Chosen](https://harvesthq.github.io/chosen/) (the library that powers Gravity Forms “Enhanced UI” option) supports it either.

This might be a good start for implementing an alternate solution:

> <https://stackoverflow.com/questions/2965971/how-to-add-images-in-select-list>

Depending on how many options you have, a Radio Button field may be an another path forward. Obviously, this would change the UX quite a bit…

We’re ([Gravity Wiz](https://gravitywiz.com/)) actively working on a solution for including images in Drop Down fields as part of our upcoming Advanced Select perk. Feel free to sign up for [our newsletter](https://gravitywiz.com/wizardly-updates/) to say in the loop.

---

<div class="post-metadata">

### Author: ![user561](https://avatars.discourse-cdn.com/v4/letter/u/e47c2d/32.png) [@user561](https://community.gravityforms.com/u/user561)
#### Post date: [November 16, 2022, 6:54pm UTC](https://community.gravityforms.com/t/dynamically-populating-drop-down/13875/3 "2022-11-16T18:54:28Z")

</div>

Thanks for the reply David.

Looks like no images for now…

---

<div class="post-metadata">

### Author: ![chrishajer](https://sea2.discourse-cdn.com/flex020/user_avatar/community.gravityforms.com/chrishajer/32/88_2.png) [@chrishajer](https://community.gravityforms.com/u/chrishajer)
#### Post date: [November 16, 2022, 10:11pm UTC](https://community.gravityforms.com/t/dynamically-populating-drop-down/13875/4 "2022-11-16T22:11:50Z")

</div>


