Fix gallery sorting not working due to change in html elements