backport of https://github.com/owncloud/gallery/pull/31 to OC6


@icewind1991 @karlitschek @PVince81 THX