Convert image file name back into file ID

By: Peter S | Asked: 06/14/2025
ForumsCategory: Code HelpConvert image file name back into file ID
Peter S asked 3 weeks ago

Hi,

I have a file upload field for images and a lookup field for it.

Normally the lookup field gets the image ID, but i am using this code to convert the ID into the file name:

//Show Image Title
add_filter( 'frm_filtered_lookup_options', 'show_lookup_image_title', 10, 2 );
function show_lookup_image_title( $options, $args ) {
if ( $args['field']->id === '20' ) { // Replace 20 with your actual field ID
foreach ( $options as $k => $option ) {
$title = get_the_title( $option );
$options[ $k ] = esc_html( $title );
}
}
return $options;
}

However, I don\'t want to store the filename, but the image ID.

I want to see the file name from the lookup field because it makes it easier to navigate but I need the entry to save the image ID.

Can anyone help?

Thanks!

1 Answers
Victor Font Staff answered 3 weeks ago

Use separate values for the lookup.

Peter S replied 3 weeks ago

Does that work if the lookup is getting values from a file upload field?

Victor Font Staff replied 3 weeks ago

It doesn't matter from where the data is derived. Separate values is a standard feature for all lookup fields.

Peter S replied 3 weeks ago

Sorry, I don't get an option for separate values on the lookup fields. I checked the formidable site and it says:
"These settings are visible only if the source field has Separate Values enabled or is a Dynamic field."

Victor Font Staff replied 3 weeks ago

<p>Then you’ve probably setup your lookup field incorrectly.</p>

Peter S replied 3 weeks ago

I don't think so.

I get my file IDs from a file upload field and because my lookup is retrieving the data from there it doesn't give me the separate values option.

I would need to get the data from a drop down field but that doesn't work in my case.

Peter S replied 3 weeks ago

Did you delete the last two messages?

Making the Best WordPress Plugin even better - Together

Take on bigger projects with confidence knowing you have access to an entire community of Formidable Experts and Professionals who have your back when the going gets tough. You got this!
Join the community
crossarrow-right