Extensions needs manual activation in VLC menu, so Lua cannot help you when you play individual files.
If you use playlist and you do not mind manual activation of extension, then you could write an extension script, that will check duration when starting to play a media and
activate the repeating within input_changed() or meta_changed() functions. Then it will need your interaction to disable the reapeating to go to play next file in playlist.
Or you can manually prepare playlist where short files will have "input-repeat=x" VLC option.
Playback control:
--input-repeat=<integer [-2147483648 .. 2147483647]>
Input repetitions
Number of time the same input will be repeated
VLC Extension Lua script could help you to generate it from your files loaded in VLC playlist (
Sampler (PG) reads the VLC playlist and generates (feeds) new playlist with items having advanced VLC options: start-time, stop-time).
If VLC plugin, then C++, not Lua.