[TwitterBridge] Display all images from a tweet (#1160)
This commit is contained in:
parent
70542686bb
commit
d34411137f
1 changed files with 47 additions and 20 deletions
|
@ -245,16 +245,19 @@ EOD;
|
|||
|
||||
// Add embeded image to content
|
||||
$image_html = '';
|
||||
$image = $this->getImageURI($tweet);
|
||||
if(!$this->getInput('noimg') && !is_null($image)) {
|
||||
$images = $this->getImageURI($tweet);
|
||||
if(!$this->getInput('noimg') && !is_null($images)) {
|
||||
|
||||
foreach ($images 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'] = array($image_orig);
|
||||
$item['enclosures'][] = $image_orig;
|
||||
|
||||
$image_html = <<<EOD
|
||||
$image_html .= <<<EOD
|
||||
<a href="{$image_orig}">
|
||||
<img
|
||||
style="align:top; max-width:558px; border:1px solid black;"
|
||||
|
@ -262,6 +265,7 @@ EOD;
|
|||
</a>
|
||||
EOD;
|
||||
}
|
||||
}
|
||||
|
||||
// add content
|
||||
$item['content'] = <<<EOD
|
||||
|
@ -291,23 +295,28 @@ EOD;
|
|||
|
||||
// Add embeded image to content
|
||||
$quotedImage_html = '';
|
||||
$quotedImage = $this->getQuotedImageURI($tweet);
|
||||
if(!$this->getInput('noimg') && !is_null($quotedImage)) {
|
||||
$quotedImages = $this->getQuotedImageURI($tweet);
|
||||
|
||||
if(!$this->getInput('noimg') && !is_null($quotedImages)) {
|
||||
|
||||
foreach ($quotedImages as $image) {
|
||||
|
||||
// Set image scaling
|
||||
$quotedImage_orig = $this->getInput('noimgscaling') ? $quotedImage : $quotedImage . ':orig';
|
||||
$quotedImage_thumb = $this->getInput('noimgscaling') ? $quotedImage : $quotedImage . ':thumb';
|
||||
$image_orig = $this->getInput('noimgscaling') ? $image : $image . ':orig';
|
||||
$image_thumb = $this->getInput('noimgscaling') ? $image : $image . ':thumb';
|
||||
|
||||
// add enclosures
|
||||
$item['enclosures'] = array($quotedImage_orig);
|
||||
$item['enclosures'][] = $image_orig;
|
||||
|
||||
$quotedImage_html = <<<EOD
|
||||
<a href="{$quotedImage_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
|
||||
{$item['content']}
|
||||
|
@ -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;
|
||||
|
|
Loading…
Reference in a new issue