UIImage + SDWebImage not showing some JPG files. Sometimes show JPEG. PNG working

StackOverflow https://stackoverflow.com/questions/21295370

  •  01-10-2022
  •  | 
  •  

سؤال

This has been bugging me and my team for over 2 days.

We're using SDWebImage to download and display pics. PNG files always work. JPG files almost always do not show. When I convert the file to png (same name, different suffix), it is shown. I've discovered that sometimes changing the file suffix from jpg to jpeg works.

The code:

 [dataContent.imageBg setImageWithURL:[NSURL URLWithString:image]     placeholderImage:[UIImage imageNamed:@"Default.png"]options:SDWebImageRefreshCached];
هل كانت مفيدة؟

المحلول

Well - We've found the problem.

Apparently the mime type for .jpg reported by our server was application.jpg. .jpeg's mime type was reported correctly as image/jpeg.

As SDWebImage validates mime type (why b.t.w?), it rejected our .jpg files.

We've corrected the mime type reported by server to be image/jpeg and everything is working fine now.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top