diff options
author | Zach Copley <zach@controlyourself.ca> | 2009-07-17 12:39:54 -0700 |
---|---|---|
committer | Zach Copley <zach@controlyourself.ca> | 2009-07-17 12:42:16 -0700 |
commit | 9c670ba695d14068d1d159a91d0699f2677dad91 (patch) | |
tree | b4102ab9dca249e8dff166dea9d3b2ae4238b8e3 /lib | |
parent | baec1320abf95cce4af49b92506de1402a95298a (diff) |
Only populate attachments array element if there are attachments
Diffstat (limited to 'lib')
-rw-r--r-- | lib/twitterapi.php | 19 |
1 files changed, 11 insertions, 8 deletions
diff --git a/lib/twitterapi.php b/lib/twitterapi.php index 66664334c..ab6c0d62c 100644 --- a/lib/twitterapi.php +++ b/lib/twitterapi.php @@ -188,15 +188,18 @@ class TwitterapiAction extends Action # Enclosures $attachments = $notice->attachments(); - $twitter_status['attachments']=array(); - if($attachments){ - foreach($attachments as $attachment){ + + if (!empty($attachments)) { + + $twitter_status['attachments'] = array(); + + foreach ($attachments as $attachment) { if ($attachment->isEnclosure()) { - $enclosure=array(); - $enclosure['url']=$attachment->url; - $enclosure['mimetype']=$attachment->mimetype; - $enclosure['size']=$attachment->size; - $twitter_status['attachments'][]=$enclosure; + $enclosure = array(); + $enclosure['url'] = $attachment->url; + $enclosure['mimetype'] = $attachment->mimetype; + $enclosure['size'] = $attachment->size; + $twitter_status['attachments'][] = $enclosure; } } } |