Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create photoUrl for original size photos correctly #18

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Classes/FlickrKit.h
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@

// Build your own from the components required
- (NSURL *) photoURLForSize:(FKPhotoSize)size photoID:(NSString *)photoID server:(NSString *)server secret:(NSString *)secret farm:(NSString *)farm;
- (NSURL *) photoURLForSize:(FKPhotoSize)size photoID:(NSString *)photoID server:(NSString *)server secret:(NSString *)secret farm:(NSString *)farm extension:(NSString *)extension;
// Utility methods to extract the photoID/server/secret/farm from the input
- (NSURL *) photoURLForSize:(FKPhotoSize)size fromPhotoDictionary:(NSDictionary *)photoDict;
- (NSURL *) buddyIconURLForUser:(NSString *)userID;
Expand Down
18 changes: 14 additions & 4 deletions Classes/FlickrKit/FlickrKit.m
Original file line number Diff line number Diff line change
Expand Up @@ -415,12 +415,22 @@ - (NSURL *) photoURLForSize:(FKPhotoSize)size fromPhotoDictionary:(NSDictionary

//Find possible secret
NSString *secret = [photoDict valueForKey:@"secret"];


return [self photoURLForSize:size photoID:photoID server:server secret:secret farm:farm];
NSString *extension = @"jpg";
if (size == FKPhotoSizeOriginal) {
// Original photos behave differently, see note here: https://www.flickr.com/services/api/misc.urls.html
// You may have to pass extras: original_format to your request in order to have these values in your response dictionary
secret = [photoDict valueForKey:@"originalsecret"];
extension = [photoDict valueForKey:@"originalformat"];
}

return [self photoURLForSize:size photoID:photoID server:server secret:secret farm:farm extension:extension];
}

- (NSURL *) photoURLForSize:(FKPhotoSize)size photoID:(NSString *)photoID server:(NSString *)server secret:(NSString *)secret farm:(NSString *)farm {
return [self photoURLForSize:size photoID:photoID server:server secret:secret farm:farm extension:@"jpg"];
}

- (NSURL *) photoURLForSize:(FKPhotoSize)size photoID:(NSString *)photoID server:(NSString *)server secret:(NSString *)secret farm:(NSString *)farm extension:(NSString *)extension {
// http://farm{farm-id}.static.flickr.com/{server-id}/{id}_{secret}_[mstb].jpg
// http://farm{farm-id}.static.flickr.com/{server-id}/{id}_{secret}.jpg

Expand All @@ -438,7 +448,7 @@ - (NSURL *) photoURLForSize:(FKPhotoSize)size photoID:(NSString *)photoID server
[URLString appendFormat:@"%@/%@_%@", server, photoID, secret];

NSString *sizeKey = FKIdentifierForSize(size);
[URLString appendFormat:@"_%@.jpg", sizeKey];
[URLString appendFormat:@"_%@.%@", sizeKey, extension];

return [NSURL URLWithString:URLString];
}
Expand Down