[TwitterBridge] Add option to disable image scaling in feeds

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
This commit is contained in:
logmanoriginal 2018-12-12 16:56:36 +01:00
parent 758f37b452
commit bb2329fa3a
1 changed files with 19 additions and 6 deletions

View File

@ -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(
@ -239,14 +244,18 @@ EOD;
$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;
}
@ -281,14 +290,18 @@ EOD;
$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;
}