Home › Forums › Add-ons › Repeater Field › Show image file-name only in admin/backend › Reply To: Show image file-name only in admin/backend
I have a quick dirty solution for you, if I am understanding the issue correctly. Since this is just temporary, this should be an OK solution for this scenario.
Now… I am assuming that:
1) You have a repeater of data
2) You don’t mind adding another field within that repeater to display the filename
Also… my brain could have overthought this issue from the beginning. There *may* be a super simple way to accomplish this. However, it only took me a few minutes, so.. here goes:
Step 1: Install the ACF Enhanced Message Field plugin, so that we can add a field to your repeater that allows for PHP code. Thanks Dreb Bits!
Step 2: Add the following code into your newly created Enhanced Message Field in your repeater:
<?php
global $my_row_number;
if ( !$my_row_number ) { $my_row_number = 0; }
$rows = get_field('repeater-name');
$specific_row = $rows[$my_row_number];
$sub_field_value = $specific_row['image-field-name'];
echo basename($sub_field_value['url']); // echos *just* the filename for the image
$my_row_number++;
?>
Sure, it’s a weird solution, but assuming I understand your issue correctly, it works like a charm 🙂
Take care to change the Repeater field name, as well as the Sub field name when using the above code.
Hope this works! Let me know.
Keith
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.