[TwitterBridge] Display all images from a tweet (#1160)

This commit is contained in:
Joseph 2019-06-09 15:24:40 +00:00 committed by LogMANOriginal
parent 70542686bb
commit d34411137f

View file

@ -245,22 +245,26 @@ EOD;
// Add embeded image to content
$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';
$images = $this->getImageURI($tweet);
if(!$this->getInput('noimg') && !is_null($images)) {
// add enclosures
$item['enclosures'] = array($image_orig);
foreach ($images as $image) {
$image_html = <<<EOD
// Set image scaling
$image_orig = $this->getInput('noimgscaling') ? $image : $image . ':orig';
$image_thumb = $this->getInput('noimgscaling') ? $image : $image . ':thumb';
// add enclosures
$item['enclosures'][] = $image_orig;
$image_html .= <<<EOD
<a href="{$image_orig}">
<img
style="align:top; max-width:558px; border:1px solid black;"
src="{$image_thumb}" />
</a>
EOD;
}
}
// add content
@ -291,22 +295,27 @@ EOD;
// Add embeded image to content
$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';
$quotedImages = $this->getQuotedImageURI($tweet);
// add enclosures
$item['enclosures'] = array($quotedImage_orig);
if(!$this->getInput('noimg') && !is_null($quotedImages)) {
$quotedImage_html = <<<EOD
<a href="{$quotedImage_orig}">
foreach ($quotedImages as $image) {
// Set image scaling
$image_orig = $this->getInput('noimgscaling') ? $image : $image . ':orig';
$image_thumb = $this->getInput('noimgscaling') ? $image : $image . ':thumb';
// add enclosures
$item['enclosures'][] = $image_orig;
$quotedImage_html .= <<<EOD
<a href="{$image_orig}">
<img
style="align:top; max-width:558px; border:1px solid black;"
src="{$quotedImage_thumb}" />
src="{$image_thumb}" />
</a>
EOD;
}
}
$item['content'] = <<<EOD
@ -360,9 +369,18 @@ EOD;
private function getImageURI($tweet){
// Find media in tweet
$images = array();
$container = $tweet->find('div.AdaptiveMedia-container', 0);
if($container && $container->find('img', 0)) {
return $container->find('img', 0)->src;
foreach ($container->find('img') as $img) {
$images[] = $img->src;
}
}
if (!empty($images)) {
return $images;
}
return null;
@ -370,9 +388,18 @@ EOD;
private function getQuotedImageURI($tweet){
// Find media in tweet
$images = array();
$container = $tweet->find('div.QuoteMedia-container', 0);
if($container && $container->find('img', 0)) {
return $container->find('img', 0)->src;
foreach ($container->find('img') as $img) {
$images[] = $img->src;
}
}
if (!empty($images)) {
return $images;
}
return null;