Skip to content

Commit

Permalink
[InstagramBridge] Add option to get direct links
Browse files Browse the repository at this point in the history
  • Loading branch information
teromene committed Oct 3, 2019
1 parent 5cc9563 commit a2e47a8
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion bridges/InstagramBridge.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,10 @@ class InstagramBridge extends BridgeAbstract {
'Picture' => 'picture',
),
'defaultValue' => 'all'
),
'direct_links' => array(
'name' => 'Use direct image links',
'type' => 'checkbox',
)
)

Expand Down Expand Up @@ -80,6 +84,8 @@ public function collectData(){
returnClientError('Stories are not supported for hashtags nor locations!');
}

$directLink = !is_null($this->getInput('direct_links')) && $this->getInput('direct_links');

$data = $this->getInstagramJSON($this->getURI());

if(!is_null($this->getInput('u'))) {
Expand Down Expand Up @@ -136,7 +142,11 @@ public function collectData(){
$item['content'] = $data[0];
$item['enclosures'] = $data[1];
} else {
$mediaURI = self::URI . 'p/' . $media->shortcode . '/media?size=l';
if($directLink) {
$mediaURI = $media->display_url;
} else {
$mediaURI = self::URI . 'p/' . $media->shortcode . '/media?size=l';
}
$item['content'] = '<a href="' . htmlentities($item['uri']) . '" target="_blank">';
$item['content'] .= '<img src="' . htmlentities($mediaURI) . '" alt="' . $item['title'] . '" />';
$item['content'] .= '</a><br><br>' . nl2br(htmlentities($textContent));
Expand Down

0 comments on commit a2e47a8

Please sign in to comment.