[3.8] Fix division by 0 in case a thumbnail has a width or height equal to 0