Conditional image loading with better masking