Skip to content

Commit

Permalink
added @warning, clearer warning msg
Browse files Browse the repository at this point in the history
  • Loading branch information
xinsight committed Jul 1, 2013
1 parent 2e95cc8 commit 2dc4478
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
8 changes: 8 additions & 0 deletions PlaceKit/UIImageView+PlaceKit.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
/** Place a random image in a specific category with a given size from lorempixel.com
@param size The size in points of your random image
@warning Image size will be clamped to max size supported by service
@param category The category that you would like your image to be chosen from. A full list of valid categories can be found at http://lorempixel.com
*/
- (void)placeRandomImageWithSize:(CGSize)size
Expand All @@ -51,6 +52,7 @@
/** Place a random greyscale image in a specific category with a given size from lorempixel.com
@param size The size in points of your random greyscale image
@warning Image size will be clamped to max size supported by service
@param category The category that you would like your image to be chosen from. A full list of valid categories can be found at http://lorempixel.com
*/
- (void)placeRandomGreyscaleImageWithSize:(CGSize)size
Expand All @@ -59,12 +61,14 @@
/** Place a random image with a given size from lorempixel.com
@param size The size in points of your random image
@warning Image size will be clamped to max size supported by service
*/
- (void)placeRandomImageWithSize:(CGSize)size;

/** Place a random greyscale image with a given size from lorempixel.com
@param size The size in points of your random greyscale image
@warning Image size will be clamped to max size supported by service
*/
- (void)placeRandomGreyscaleImageWithSize:(CGSize)size;

Expand All @@ -89,20 +93,24 @@
/** Place a random image in a specific category with an inherited size from lorempixel.com
@param category The category that you would like your image to be chosen from. A full list of valid categories can be found at http://lorempixel.com
@warning Image size will be clamped to max size supported by service
*/
- (void)placeRandomImageFromCategory:(NSString *)category;

/** Place a random greyscale image in a specific category with an inherited size from lorempixel.com
@param category The category that you would like your image to be chosen from. A full list of valid categories can be found at http://lorempixel.com
@warning Image size will be clamped to max size supported by service
*/
- (void)placeRandomGreyscaleImageFromCategory:(NSString *)category;

/** Place a random image with an inherited size from lorempixel.com
@warning Image size will be clamped to max size supported by service
*/
- (void)placeRandomImage;

/** Place a random greyscale image with an inherited size from lorempixel.com
@warning Image size will be clamped to max size supported by service
*/
- (void)placeRandomGreyscaleImage;

Expand Down
5 changes: 3 additions & 2 deletions PlaceKit/UIImageView+PlaceKit.m
Original file line number Diff line number Diff line change
Expand Up @@ -82,12 +82,13 @@ - (void)placeImageWithURLString:(NSString *)path size:(CGSize)size{
CGFloat screenScale = [[UIScreen mainScreen] scale];
CGFloat w = size.width*screenScale;
CGFloat h = size.height*screenScale;
if ([path rangeOfString:@"lorempixel.com"].length > 0) {
NSString *service = @"lorempixel.com";
if ([path rangeOfString:service].length > 0) {
CGFloat max = 1920.0f;
if (w > max || h > max) {
w = MIN(w,max);
h = MIN(h,max);
NSLog(@"%s: Warn: requested image size > max. using %.0fx%.0f", __PRETTY_FUNCTION__, w, h);
NSLog(@"%s: Warn: clamping image size to %@ max size. using %.0fx%.0f", __PRETTY_FUNCTION__, service, w, h);
}
}
NSString *urlString = [NSString stringWithFormat:path, w, h];
Expand Down

0 comments on commit 2dc4478

Please sign in to comment.