Media files starting with underscore are ignored?

It seems like Kirby 3 ignores media files (e.g. images) with filenames that start with an underscore (e.g. _dsc6359.jpg). If I call $page->images()->count() it returns 0. If I remove the underscore it returns 1. Is this intended behavior?

Underscore prefixes are actually sanitized/removed when you upload files through the Panel whereas underscores inside of filenames aren’t. So I guess this behavior is somehow intended.

At least, that’s what the Str::slug() method which is used internally in F::safeName() does.

// trim leading and trailing non-word-chars
$string = preg_replace('!^[^a-z0-9]+!', '', $string);
$string = preg_replace('![^a-z0-9]+$!', '', $string);

Alright, looks like I have to rename the files, as I’m migrating an old site to Kirby 3 and the files are already there. Thanks!

@texnixe Maybe this could be mentioned in the upgrade guide?

I’ve added an issue on GitHub:

1 Like