[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',
),
'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!');
}
$directLink = !is_null($this->getInput('direct_links')) && $this->getInput('direct_links');
$data = $this->getInstagramJSON($this->getURI());
if(!is_null($this->getInput('u'))) {
@ -136,7 +142,11 @@ class InstagramBridge extends BridgeAbstract {
$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));