From bb2329fa3a992ad22e5deaa112557f732fe4a627 Mon Sep 17 00:00:00 2001
From: logmanoriginal <logmanoriginal@users.noreply.github.com>
Date: Wed, 12 Dec 2018 16:56:36 +0100
Subject: [PATCH] [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
---
 bridges/TwitterBridge.php | 25 +++++++++++++++++++------
 1 file changed, 19 insertions(+), 6 deletions(-)

diff --git a/bridges/TwitterBridge.php b/bridges/TwitterBridge.php
index 20f90d74..32ed9428 100644
--- a/bridges/TwitterBridge.php
+++ b/bridges/TwitterBridge.php
@@ -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;
 				}