Skip to content

Commit

Permalink
[TwitterBridge] Add option to disable image scaling in feeds
Browse files Browse the repository at this point in the history
Images in Twitter feeds are currently being scaled by adding ':orig'
(original image) and ':thumb' (thumbnail) to image URIs in the feed.

This can cause issues with feed readers that don't handle colons in
URIs correctly.

Image scaling can now be disabled by adding '&noimgscaling=on' to the
query. This parameter is optional to stay compatible to existing feeds.

References #957
  • Loading branch information
logmanoriginal committed Dec 12, 2018
1 parent 758f37b commit bb2329f
Showing 1 changed file with 19 additions and 6 deletions.
25 changes: 19 additions & 6 deletions bridges/TwitterBridge.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,11 @@ class TwitterBridge extends BridgeAbstract {
'name' => 'Hide images in tweets',
'type' => 'checkbox',
'title' => 'Activate to hide images in tweets'
),
'noimgscaling' => array(
'name' => 'Disable image scaling',
'type' => 'checkbox',
'title' => 'Activate to disable image scaling in tweets (keeps original image)'
)
),
'By keyword or hashtag' => array(
Expand Down Expand Up @@ -239,14 +244,18 @@ public function collectData(){
$image_html = '';
$image = $this->getImageURI($tweet);
if(!$this->getInput('noimg') && !is_null($image)) {
// Set image scaling
$image_orig = $this->getInput('noimgscaling') ? $image : $image . ':orig';
$image_thumb = $this->getInput('noimgscaling') ? $image : $image . ':thumb';

// add enclosures
$item['enclosures'] = array($image . ':orig');
$item['enclosures'] = array($image_orig);

$image_html = <<<EOD
<a href="{$image}:orig">
<a href="{$image_orig}">
<img
style="align:top; max-width:558px; border:1px solid black;"
src="{$image}:thumb" />
src="{$image_thumb}" />
</a>
EOD;
}
Expand Down Expand Up @@ -281,14 +290,18 @@ public function collectData(){
$quotedImage_html = '';
$quotedImage = $this->getQuotedImageURI($tweet);
if(!$this->getInput('noimg') && !is_null($quotedImage)) {
// Set image scaling
$quotedImage_orig = $this->getInput('noimgscaling') ? $quotedImage : $quotedImage . ':orig';
$quotedImage_thumb = $this->getInput('noimgscaling') ? $quotedImage : $quotedImage . ':thumb';

// add enclosures
$item['enclosures'] = array($quotedImage . ':orig');
$item['enclosures'] = array($quotedImage_orig);

$quotedImage_html = <<<EOD
<a href="{$quotedImage}:orig">
<a href="{$quotedImage_orig}">
<img
style="align:top; max-width:558px; border:1px solid black;"
src="{$quotedImage}:thumb" />
src="{$quotedImage_thumb}" />
</a>
EOD;
}
Expand Down

0 comments on commit bb2329f

Please sign in to comment.