Skip to content

Commit

Permalink
Merge pull request #209 from jasonadkison/bugfix/media-caption
Browse files Browse the repository at this point in the history
safe access media caption array element
  • Loading branch information
raiym authored Nov 10, 2017
2 parents e819fe2 + 2b13036 commit 980b1ce
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/InstagramScraper/Model/Media.php
Original file line number Diff line number Diff line change
Expand Up @@ -459,7 +459,14 @@ protected function initPropertiesCustom($value, $prop, $arr)
$this->imageThumbnailUrl = $images['thumbnail'];
break;
case 'edge_media_to_caption':
$this->caption = $arr[$prop]['edges'][0]['node']['text'];
if (is_array($arr[$prop]['edges']) && !empty($arr[$prop]['edges'])) {
$first_caption = $arr[$prop]['edges'][0];
if (is_array($first_caption) && isset($first_caption['node'])) {
if (is_array($first_caption['node']) && isset($first_caption['node']['text'])) {
$this->caption = $arr[$prop]['edges'][0]['node']['text'];
}
}
}
break;
case 'owner':
$this->owner = Account::create($arr[$prop]);
Expand Down

0 comments on commit 980b1ce

Please sign in to comment.