Uplift fix for Bug 1027371 - gallery thumbnail locator changes to 1.4 from master

Uplifts patch from the master branch to v1.4 branch to fix the new locator