This repository was archived by the owner on Feb 2, 2023. It is now read-only.
File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -188,14 +188,23 @@ - (void)_lazilyLoadImageIfNecessary
188188 ASDN::MutexLocker l (_lock);
189189
190190 dispatch_async (dispatch_get_main_queue (), ^{
191- _imageLoaded = YES ;
192-
193191 if (self.shouldCacheImage ) {
194- self.image = [UIImage imageNamed: _URL.path];
192+ self.image = [UIImage imageNamed: _URL.path.lastPathComponent ];
195193 } else {
194+ // First try to load the path directly, for efficiency assuming a developer who
195+ // doesn't want caching is trying to be as minimal as possible.
196196 self.image = [UIImage imageWithContentsOfFile: _URL.path];
197+ if (!self.image ) {
198+ // If we couldn't find it, execute an -imageNamed:-like search so we can find resources even if the
199+ // extension is not provided in the path. This allows the same path to work regardless of shouldCacheImage.
200+ NSString *filename = [[NSBundle mainBundle ] pathForResource: _URL.path.lastPathComponent ofType: nil ];
201+ if (filename) {
202+ self.image = [UIImage imageWithContentsOfFile: filename];
203+ }
204+ }
197205 }
198-
206+
207+ _imageLoaded = YES ;
199208 [_delegate imageNode: self didLoadImage: self .image];
200209 });
201210 }
You can’t perform that action at this time.
0 commit comments