@@ -20,18 +20,19 @@ class Instagram extends Tags
2020 public function index ()
2121 {
2222 $ limit = $ this ->params ->int ('limit ' , 12 );
23+ $ profileHandle = $ this ->params ->get ('profile ' );
2324
24- $ cache_key = config ('statamic-instagram.cache.key_prefix ' ).'_ ' .$ limit ;
25+ $ cache_key = config ('statamic-instagram.cache.key_prefix ' ).'_ ' .$ profileHandle . ' _ ' . $ limit ;
2526
26- if (! $ profileHandle = $ this -> params -> get ( ' profile ' ) ) {
27+ if (! $ profileHandle ) {
2728 return [];
2829 }
2930
3031 try {
3132 return $ this ->output (Cache::remember (
3233 $ cache_key ,
3334 now ()->addSeconds (config ('statamic-instagram.cache.duration ' )),
34- fn () => $ this ->getData ($ profileHandle , $ limit )
35+ fn () => $ this ->getData ($ profileHandle , $ limit )
3536 ));
3637 } catch (\Exception $ exception ) {
3738 Log::alert ('Instagram error : ' .$ exception ->getMessage ());
@@ -74,7 +75,7 @@ private function getMedia(Profile $profile, $limit = 12): array
7475 $ profile = app (Api::class)->getMoreMedias ($ profile );
7576
7677 $ media = array_merge ($ media , $ profile ->getMedias ());
77- } while (count ($ media ) < $ limit && $ profile ->hasMoreMedias ());
78+ } while (count ($ media ) < $ limit && $ profile ->hasMoreMedias ());
7879
7980 return collect ($ media )
8081 ->take ($ limit )
@@ -83,7 +84,7 @@ private function getMedia(Profile $profile, $limit = 12): array
8384 $ media ['date ' ] = Carbon::parse ($ media ['date ' ]);
8485
8586 if ($ media ['video ' ]) {
86- $ mediaClass = new Media () ;
87+ $ mediaClass = new Media ;
8788 $ mediaClass ->setLink ($ media ['link ' ]);
8889
8990 $ media ['videoUrl ' ] = app (Api::class)->getMediaDetailed ($ mediaClass )?->getVideoUrl();
0 commit comments