Skip to content
This repository was archived by the owner on Sep 15, 2025. It is now read-only.

Commit b5a1f26

Browse files
author
Gerardo Pacheco
authored
Merge pull request #529 from wordpress-mobile/add/media-large-medium-sizes
MediaService - Add large and medium sizes
2 parents 3f5800a + 9d9efb4 commit b5a1f26

File tree

3 files changed

+12
-0
lines changed

3 files changed

+12
-0
lines changed

WordPressKit/MediaServiceRemoteREST.m

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -361,6 +361,8 @@ + (RemoteMedia *)remoteMediaFromJSONDictionary:(NSDictionary *)jsonMedia
361361
remoteMedia.date = [NSDate dateWithWordPressComJSONString:jsonMedia[@"date"]];
362362
remoteMedia.postID = [jsonMedia numberForKey:@"post_ID"];
363363
remoteMedia.file = [jsonMedia stringForKey:@"file"];
364+
remoteMedia.largeURL = [NSURL URLWithString:[jsonMedia valueForKeyPath :@"thumbnails.large"]];
365+
remoteMedia.mediumURL = [NSURL URLWithString:[jsonMedia valueForKeyPath :@"thumbnails.medium"]];
364366
remoteMedia.mimeType = [jsonMedia stringForKey:@"mime_type"];
365367
remoteMedia.extension = [jsonMedia stringForKey:@"extension"];
366368
remoteMedia.title = [jsonMedia stringForKey:@"title"];

WordPressKit/MediaServiceRemoteXMLRPC.m

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -272,6 +272,14 @@ - (RemoteMedia *)remoteMediaFromXMLRPCDictionary:(NSDictionary*)xmlRPC
272272
link = [xmlRPC stringForKeyPath:@"link"];
273273
}
274274
remoteMedia.file = [link lastPathComponent] ?: [[xmlRPC objectForKeyPath:@"file"] lastPathComponent];
275+
276+
if ([xmlRPC valueForKeyPath:@"metadata.sizes.large.file"] != nil) {
277+
remoteMedia.largeURL = [NSURL URLWithString: [NSString stringWithFormat:@"%@%@", remoteMedia.url.URLByDeletingLastPathComponent, [xmlRPC valueForKeyPath:@"metadata.sizes.large.file"]]];
278+
}
279+
280+
if ([xmlRPC valueForKeyPath:@"metadata.sizes.medium.file"] != nil) {
281+
remoteMedia.mediumURL = [NSURL URLWithString: [NSString stringWithFormat:@"%@%@", remoteMedia.url.URLByDeletingLastPathComponent, [xmlRPC valueForKeyPath:@"metadata.sizes.medium.file"]]];
282+
}
275283

276284
if (xmlRPC[@"date_created_gmt"] != nil) {
277285
remoteMedia.date = xmlRPC[@"date_created_gmt"];

WordPressKit/RemoteMedia.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
@property (nonatomic, strong, nullable) NSNumber *mediaID;
66
@property (nonatomic, strong, nullable) NSURL *url;
77
@property (nonatomic, strong, nullable) NSURL *localURL;
8+
@property (nonatomic, strong, nullable) NSURL *largeURL;
9+
@property (nonatomic, strong, nullable) NSURL *mediumURL;
810
@property (nonatomic, strong, nullable) NSURL *guid;
911
@property (nonatomic, strong, nullable) NSDate *date;
1012
@property (nonatomic, strong, nullable) NSNumber *postID;

0 commit comments

Comments
 (0)