1
0
Fork 0
mirror of https://github.com/wallabag/wallabag.git synced 2025-09-15 18:57:05 +00:00

Display a bigger image in case of image content

If the content is only an image, we can display a bigger preview image because we won’t have text to display.

Also, split different card view to avoid too much complexity in the entries.html.twig
This commit is contained in:
Jeremy Benoist 2016-11-08 22:17:46 +01:00
parent e9490a3443
commit 8d7b4f0eff
No known key found for this signature in database
GPG key ID: BCA73962457ACC3C
10 changed files with 164 additions and 97 deletions

View file

@ -8,6 +8,7 @@ use Wallabag\CoreBundle\Entity\Entry;
use Wallabag\CoreBundle\Entity\Tag;
use Wallabag\CoreBundle\Tools\Utils;
use Wallabag\CoreBundle\Repository\TagRepository;
use Symfony\Component\HttpFoundation\File\MimeType\MimeTypeExtensionGuesser;
/**
* This kind of proxy class take care of getting the content from an url
@ -19,6 +20,7 @@ class ContentProxy
protected $tagger;
protected $logger;
protected $tagRepository;
protected $mimeGuesser;
public function __construct(Graby $graby, RuleBasedTagger $tagger, TagRepository $tagRepository, Logger $logger)
{
@ -26,6 +28,7 @@ class ContentProxy
$this->tagger = $tagger;
$this->logger = $logger;
$this->tagRepository = $tagRepository;
$this->mimeGuesser = new MimeTypeExtensionGuesser();
}
/**
@ -79,6 +82,11 @@ class ContentProxy
$entry->setPreviewPicture($content['open_graph']['og_image']);
}
// if content is an image define as a preview too
if (in_array($this->mimeGuesser->guess($content['content_type']), ['jpeg', 'jpg', 'gif', 'png'], true)) {
$entry->setPreviewPicture($content['url']);
}
try {
$this->tagger->tag($entry);
} catch (\Exception $e) {