aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/Wallabag/CoreBundle/Helper/ContentProxy.php
diff options
context:
space:
mode:
authorJeremy Benoist <jeremy.benoist@gmail.com>2016-11-08 22:17:46 +0100
committerJeremy Benoist <jeremy.benoist@gmail.com>2016-11-08 22:17:46 +0100
commit8d7b4f0eff9d07f8d6d354e09fd926abf26aa4ce (patch)
treef8a932f9e991ae49578bff9c70b27fffd78a929c /src/Wallabag/CoreBundle/Helper/ContentProxy.php
parente9490a344376036978956aedeb213066fdbf49e4 (diff)
downloadwallabag-8d7b4f0eff9d07f8d6d354e09fd926abf26aa4ce.tar.gz
wallabag-8d7b4f0eff9d07f8d6d354e09fd926abf26aa4ce.tar.zst
wallabag-8d7b4f0eff9d07f8d6d354e09fd926abf26aa4ce.zip
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
Diffstat (limited to 'src/Wallabag/CoreBundle/Helper/ContentProxy.php')
-rw-r--r--src/Wallabag/CoreBundle/Helper/ContentProxy.php8
1 files changed, 8 insertions, 0 deletions
diff --git a/src/Wallabag/CoreBundle/Helper/ContentProxy.php b/src/Wallabag/CoreBundle/Helper/ContentProxy.php
index 8019df42..bbd5db5d 100644
--- a/src/Wallabag/CoreBundle/Helper/ContentProxy.php
+++ b/src/Wallabag/CoreBundle/Helper/ContentProxy.php
@@ -8,6 +8,7 @@ use Wallabag\CoreBundle\Entity\Entry;
8use Wallabag\CoreBundle\Entity\Tag; 8use Wallabag\CoreBundle\Entity\Tag;
9use Wallabag\CoreBundle\Tools\Utils; 9use Wallabag\CoreBundle\Tools\Utils;
10use Wallabag\CoreBundle\Repository\TagRepository; 10use Wallabag\CoreBundle\Repository\TagRepository;
11use Symfony\Component\HttpFoundation\File\MimeType\MimeTypeExtensionGuesser;
11 12
12/** 13/**
13 * This kind of proxy class take care of getting the content from an url 14 * This kind of proxy class take care of getting the content from an url
@@ -19,6 +20,7 @@ class ContentProxy
19 protected $tagger; 20 protected $tagger;
20 protected $logger; 21 protected $logger;
21 protected $tagRepository; 22 protected $tagRepository;
23 protected $mimeGuesser;
22 24
23 public function __construct(Graby $graby, RuleBasedTagger $tagger, TagRepository $tagRepository, Logger $logger) 25 public function __construct(Graby $graby, RuleBasedTagger $tagger, TagRepository $tagRepository, Logger $logger)
24 { 26 {
@@ -26,6 +28,7 @@ class ContentProxy
26 $this->tagger = $tagger; 28 $this->tagger = $tagger;
27 $this->logger = $logger; 29 $this->logger = $logger;
28 $this->tagRepository = $tagRepository; 30 $this->tagRepository = $tagRepository;
31 $this->mimeGuesser = new MimeTypeExtensionGuesser();
29 } 32 }
30 33
31 /** 34 /**
@@ -79,6 +82,11 @@ class ContentProxy
79 $entry->setPreviewPicture($content['open_graph']['og_image']); 82 $entry->setPreviewPicture($content['open_graph']['og_image']);
80 } 83 }
81 84
85 // if content is an image define as a preview too
86 if (in_array($this->mimeGuesser->guess($content['content_type']), ['jpeg', 'jpg', 'gif', 'png'], true)) {
87 $entry->setPreviewPicture($content['url']);
88 }
89
82 try { 90 try {
83 $this->tagger->tag($entry); 91 $this->tagger->tag($entry);
84 } catch (\Exception $e) { 92 } catch (\Exception $e) {