ソースを参照

[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
logmanoriginal 6 年 前
コミット
7dda088b3f
1 ファイル変更23 行追加0 行削除
  1. 23 0
      bridges/InstagramBridge.php

+ 23 - 0
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'] = '<img src="' . htmlentities($media->display_src) . '" />';