tinyfilemanager icon indicating copy to clipboard operation
tinyfilemanager copied to clipboard

Display Filenames get trimmed & unneeded columns for public display

Open darrenbirks opened this issue 6 months ago • 1 comments

The filenames displayed in the file manager get cut short and displayed with "..." after them.

This seems unnecessary (or at least I would like to be able to increase the length)

In addition, I would prefer not to display the columns that show the file permissions & owner as they mean nothing to end users. We could use way to configure these.

darrenbirks avatar Jun 09 '25 17:06 darrenbirks

I asked Copilot. Maybe it is useful for a PR.

Here’s how you can make both the filename length and the visibility of the permissions/owner columns configurable in tinyfilemanager.php. This will allow you to adjust these settings without editing the code every time.

Step 1: Add Configuration Variables

At the very top of tinyfilemanager.php (just after the opening <?php tag and comments), add the following configuration options:

// === Custom Configurations ===
$max_filename_length = 100; // Set to 0 for unlimited filename length (no truncation)
$show_permissions_column = false; // Set to false to hide permissions column
$show_owner_column = false; // Set to false to hide owner column
// =============================

You can adjust these settings as needed.

Step 2: Update Filename Truncation Logic

Find where the filenames are displayed in the directory listing table. It might look something like this:

echo htmlspecialchars($file['name']); or

echo substr($file['name'], 0, 20) . '...';

Replace it with the following logic:

$display_name = $file['name'];
if ($max_filename_length > 0 && mb_strlen($display_name) > $max_filename_length) {
    $display_name = mb_substr($display_name, 0, $max_filename_length) . '...';
}
echo htmlspecialchars($display_name);

This will use your configuration for truncation. If you set $max_filename_length = 0, filenames won’t be truncated at all.

Step 3: Conditionally Show/Hide Permissions & Owner Columns

3.1. Table Header ()

Look for where the table headers are rendered. You’ll see something like:

<th>Permissions</th>
<th>Owner</th>

Wrap these in an if statement:

<?php if ($show_permissions_column): ?>
    <th>Permissions</th>
<?php endif; ?>
<?php if ($show_owner_column): ?>
    <th>Owner</th>
<?php endif; ?>

3.2. Table Body ()

Similarly, find where the permissions and owner values are output for each file row:

<td><?php echo $file['permissions']; ?></td>
<td><?php echo $file['owner']; ?></td>

Wrap these:

<?php if ($show_permissions_column): ?>
    <td><?php echo $file['permissions']; ?></td>
<?php endif; ?>
<?php if ($show_owner_column): ?>
    <td><?php echo $file['owner']; ?></td>
<?php endif; ?>

Step 4: Save and Test

Save the modified tinyfilemanager.php. Refresh your file manager in the browser. Adjust the configuration variables as needed to see the changes take effect.

Summary

Add three config variables at the top. Use those variables to control filename length and which columns to show. No core logic or security is affected—just display. If you want the exact lines to change, let me know and I can help you find them in your version of tinyfilemanager.php.

smalos avatar Jun 19 '25 09:06 smalos