Make sql query DB independant
Add new option ('Thumbnail output format')