Revision: 29438
          http://sourceforge.net/p/bibdesk/svn/29438
Author:   hofman
Date:     2025-08-20 08:58:26 +0000 (Wed, 20 Aug 2025)
Log Message:
-----------
get image data for we protocol from bundle when available

Modified Paths:
--------------
    trunk/bibdesk/BDSKBibDeskProtocol.m

Modified: trunk/bibdesk/BDSKBibDeskProtocol.m
===================================================================
--- trunk/bibdesk/BDSKBibDeskProtocol.m 2025-08-18 21:14:54 UTC (rev 29437)
+++ trunk/bibdesk/BDSKBibDeskProtocol.m 2025-08-20 08:58:26 UTC (rev 29438)
@@ -106,8 +106,21 @@
         [self loadData:[icon TIFFRepresentation] MIMEType:@"image/tiff"];
     } else if ([resourceSpecifier hasCaseInsensitivePrefix:IMAGE_SPECIFIER]) {
         NSString *name = [[resourceSpecifier 
substringFromIndex:[IMAGE_SPECIFIER length]] stringByRemovingPercentEncoding];
-        NSImage *image = [NSImage imageNamed:name];
-        [self loadData:[image TIFFRepresentation] MIMEType:@"image/tiff"];
+        NSURL *imgURL = [[NSBundle mainBundle] URLForImageResource:name];
+        NSString *MIMEType = nil;
+        NSData *data = nil;
+        if (imgURL) {
+            NSString *type = [[NSWorkspace sharedWorkspace] typeOfFile:[imgURL 
path] error:NULL];
+            if (type) {
+                MIMEType = 
CFBridgingRelease(UTTypeCopyPreferredTagWithClass((__bridge CFStringRef)type, 
kUTTagClassMIMEType));
+                data = [[NSData alloc] initWithContentsOfURL:imgURL];
+            }
+        }
+        if (data == nil || MIMEType == nil) {
+            data = [[NSImage imageNamed:name] TIFFRepresentation];
+            MIMEType = @"image/tiff";
+        }
+        [self loadData:data MIMEType:MIMEType];
     } else if ([HELP_SPECIFIER isCaseInsensitiveEqual:[[resourceSpecifier 
pathComponents] firstObject]]) {
         // when there's no "//" the URL we get has percent escapes including 
in particular the # character, which would we don't want
         NSString *URLString = [NSString stringWithFormat:@"%@://%@", 
BDSKBibDeskScheme, [resourceSpecifier stringByRemovingPercentEncoding]];

This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.



_______________________________________________
Bibdesk-commit mailing list
Bibdesk-commit@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/bibdesk-commit

Reply via email to