Home Forums Add-ons Repeater Field Show image file-name only in admin/backend Reply To: Show image file-name only in admin/backend

  • @tobiasheuken

    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:

    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

    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.