From 8419330e42c0c6c5c2a3ddaf136bf593c2e7aa8a Mon Sep 17 00:00:00 2001 From: Sergio Estevao Date: Wed, 20 Nov 2019 10:54:28 +0000 Subject: [PATCH] Add support for media on private sites. --- .../ViewRelated/Gutenberg/GutenbergViewController.swift | 3 ++- WordPress/Classes/ViewRelated/Reader/WPImageViewController.h | 2 ++ WordPress/Classes/ViewRelated/Reader/WPImageViewController.m | 5 ++++- 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/WordPress/Classes/ViewRelated/Gutenberg/GutenbergViewController.swift b/WordPress/Classes/ViewRelated/Gutenberg/GutenbergViewController.swift index 76f844e6fadf..76e73d8f5e27 100644 --- a/WordPress/Classes/ViewRelated/Gutenberg/GutenbergViewController.swift +++ b/WordPress/Classes/ViewRelated/Gutenberg/GutenbergViewController.swift @@ -544,7 +544,8 @@ extension GutenbergViewController: GutenbergBridgeDelegate { } func gutenbergDidRequestFullscreenImage(with mediaUrl: URL) { - let controller = WPImageViewController(url: mediaUrl) + let controller = WPImageViewController(externalMediaURL: mediaUrl) + controller.post = self.post controller.modalTransitionStyle = .crossDissolve controller.modalPresentationStyle = .fullScreen self.present(controller, animated: true) diff --git a/WordPress/Classes/ViewRelated/Reader/WPImageViewController.h b/WordPress/Classes/ViewRelated/Reader/WPImageViewController.h index 4bd41ff71359..477e4dd55f7b 100644 --- a/WordPress/Classes/ViewRelated/Reader/WPImageViewController.h +++ b/WordPress/Classes/ViewRelated/Reader/WPImageViewController.h @@ -4,12 +4,14 @@ @import WPMediaPicker; @class Media; +@class AbstractPost; NS_ASSUME_NONNULL_BEGIN @interface WPImageViewController : UIViewController @property (nonatomic, readonly, nullable) id mediaAsset; @property (nonatomic, assign) BOOL shouldDismissWithGestures; +@property (nonatomic, weak) AbstractPost* post; - (instancetype)initWithImage:(UIImage *)image; - (instancetype)initWithURL:(NSURL *)url; diff --git a/WordPress/Classes/ViewRelated/Reader/WPImageViewController.m b/WordPress/Classes/ViewRelated/Reader/WPImageViewController.m index aca205596722..7e5c58a93765 100644 --- a/WordPress/Classes/ViewRelated/Reader/WPImageViewController.m +++ b/WordPress/Classes/ViewRelated/Reader/WPImageViewController.m @@ -314,8 +314,11 @@ - (void)loadImageFromExternalURL { self.isLoadingImage = YES; - __weak __typeof__(self) weakSelf = self; + __weak __typeof__(self) weakSelf = self; [self.imageLoader loadImageWithURL:self.url + fromPost:self.post + preferredSize:CGSizeZero + placeholder:nil success:^{ weakSelf.isLoadingImage = NO; weakSelf.image = weakSelf.imageView.image;