[InstagramBridge] Add option to get direct links

This commit is contained in:
Lyra 2019-10-03 22:14:21 +02:00
parent 5cc956367f
commit a2e47a88c3

View file

@ -37,6 +37,10 @@ class InstagramBridge extends BridgeAbstract {
'Picture' => 'picture', 'Picture' => 'picture',
), ),
'defaultValue' => 'all' 'defaultValue' => 'all'
),
'direct_links' => array(
'name' => 'Use direct image links',
'type' => 'checkbox',
) )
) )
@ -80,6 +84,8 @@ class InstagramBridge extends BridgeAbstract {
returnClientError('Stories are not supported for hashtags nor locations!'); 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()); $data = $this->getInstagramJSON($this->getURI());
if(!is_null($this->getInput('u'))) { if(!is_null($this->getInput('u'))) {
@ -135,8 +141,12 @@ class InstagramBridge extends BridgeAbstract {
$data = $this->getInstagramStory($item['uri']); $data = $this->getInstagramStory($item['uri']);
$item['content'] = $data[0]; $item['content'] = $data[0];
$item['enclosures'] = $data[1]; $item['enclosures'] = $data[1];
} else {
if($directLink) {
$mediaURI = $media->display_url;
} else { } else {
$mediaURI = self::URI . 'p/' . $media->shortcode . '/media?size=l'; $mediaURI = self::URI . 'p/' . $media->shortcode . '/media?size=l';
}
$item['content'] = '<a href="' . htmlentities($item['uri']) . '" target="_blank">'; $item['content'] = '<a href="' . htmlentities($item['uri']) . '" target="_blank">';
$item['content'] .= '<img src="' . htmlentities($mediaURI) . '" alt="' . $item['title'] . '" />'; $item['content'] .= '<img src="' . htmlentities($mediaURI) . '" alt="' . $item['title'] . '" />';
$item['content'] .= '</a><br><br>' . nl2br(htmlentities($textContent)); $item['content'] .= '</a><br><br>' . nl2br(htmlentities($textContent));