Home › Forums › Add-ons › Repeater Field › Show image file-name only in admin/backend › Reply To: Show image file-name only in admin/backend
That’s weird. Can’t be sure why that is.
I have a different approach:
1) Create a regular text field. Make note of the ‘key’. You can expose the key by clicking Screen Options at the top right of the Edit Fields screen.
2) Add the code below to a Custom Plugin or functions file.
In the ‘add_filter’ line, of course, use your key from Step 1.
You can also change ‘full’ to some other image size, to get the image filename you are after.
function my_acf_load_value( $value, $post_id, $field ) {
global $my_row_number;
if ( !$my_row_number ) { $my_row_number = 0; }
$meta_key = 'allgemein_mitglied_'.$my_row_number.'_allgemein_profilbild';
$sub_field_value = get_post_meta( $post_id, $meta_key, true );
$image_attributes = wp_get_attachment_image_src( $sub_field_value, 'full' );
$value = basename( $image_attributes[0] );
$my_row_number++;
return $value;
}
add_filter('acf/load_value/key=field_59c9182f21022', 'my_acf_load_value', 10, 3);
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Privacy Policy. If you continue to use this site, you consent to our use of cookies.