From 7dda088b3ff8fea5ca712d51d2c8fd0ad8f3709a Mon Sep 17 00:00:00 2001 From: logmanoriginal Date: Tue, 25 Jul 2017 15:10:06 +0200 Subject: [PATCH] [InstagramBridge] Add option to filter for videos and pictures Adds a new option 'media_type' to select from three choices: - 'all' (Both): Returns pictures and videos (default choice) - 'picture': Returns only pictures - 'video': Returns only videos References #553 --- bridges/InstagramBridge.php | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/bridges/InstagramBridge.php b/bridges/InstagramBridge.php index 42f55ce6..4df5a799 100644 --- a/bridges/InstagramBridge.php +++ b/bridges/InstagramBridge.php @@ -10,6 +10,17 @@ class InstagramBridge extends BridgeAbstract { 'u' => array( 'name' => 'username', 'required' => true + ), + 'media_type' => array( + 'name' => 'Media type', + 'type' => 'list', + 'required' => false, + 'values' => array( + 'Both' => 'all', + 'Video' => 'video', + 'Picture' => 'picture' + ), + 'defaultValue' => 'all' ) )); @@ -39,6 +50,18 @@ class InstagramBridge extends BridgeAbstract { $userMedia = $data->entry_data->ProfilePage[0]->user->media->nodes; foreach($userMedia as $media){ + // Check media type + switch($this->getInput('media_type')){ + case 'all': break; + case 'video': + if($media->is_video === false) continue 2; + break; + case 'picture': + if($media->is_video === true) continue 2; + break; + default: break; + } + $item = array(); $item['uri'] = self::URI . 'p/' . $media->code . '/'; $item['content'] = '';