Backport preview fixes stable7

please approve @karlitschek @craigpg 

backports https://github.com/owncloud/core/pull/10639 and https://github.com/owncloud/core/pull/11741