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