aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/Wallabag/CoreBundle/Helper/ContentProxy.php
diff options
context:
space:
mode:
authorJeremy Benoist <jeremy.benoist@gmail.com>2016-11-19 15:30:49 +0100
committerJeremy Benoist <jeremy.benoist@gmail.com>2016-11-19 15:30:49 +0100
commit68003139e133835805b143b62c4407f19b495dab (patch)
tree9a71a15d021330fb6d55cc338f125161ddfc61dd /src/Wallabag/CoreBundle/Helper/ContentProxy.php
parentbbd4ae7b56d9db744482a5630abad350f2d819af (diff)
parentcb1a6590c0e58c56d0612066501b3a586b103ed5 (diff)
downloadwallabag-68003139e133835805b143b62c4407f19b495dab.tar.gz
wallabag-68003139e133835805b143b62c4407f19b495dab.tar.zst
wallabag-68003139e133835805b143b62c4407f19b495dab.zip
Merge remote-tracking branch 'origin/master' into 2.2
# Conflicts: # .editorconfig # docs/de/index.rst # docs/de/user/import.rst # docs/en/index.rst # docs/en/user/configuration.rst # docs/en/user/import.rst # docs/fr/index.rst # docs/fr/user/import.rst # src/Wallabag/CoreBundle/Command/InstallCommand.php # src/Wallabag/CoreBundle/Resources/translations/messages.da.yml # src/Wallabag/CoreBundle/Resources/translations/messages.de.yml # src/Wallabag/CoreBundle/Resources/translations/messages.en.yml # src/Wallabag/CoreBundle/Resources/translations/messages.es.yml # src/Wallabag/CoreBundle/Resources/translations/messages.fa.yml # src/Wallabag/CoreBundle/Resources/translations/messages.fr.yml # src/Wallabag/CoreBundle/Resources/translations/messages.it.yml # src/Wallabag/CoreBundle/Resources/translations/messages.oc.yml # src/Wallabag/CoreBundle/Resources/translations/messages.pl.yml # src/Wallabag/CoreBundle/Resources/translations/messages.pt.yml # src/Wallabag/CoreBundle/Resources/translations/messages.ro.yml # src/Wallabag/CoreBundle/Resources/translations/messages.tr.yml # src/Wallabag/CoreBundle/Resources/views/themes/baggy/Config/index.html.twig # web/bundles/wallabagcore/themes/baggy/css/style.min.css # web/bundles/wallabagcore/themes/baggy/js/baggy.min.js # web/bundles/wallabagcore/themes/material/css/style.min.css # web/bundles/wallabagcore/themes/material/js/material.min.js
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 178910ab..fd059325 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, LoggerInterface $logger) 25 public function __construct(Graby $graby, RuleBasedTagger $tagger, TagRepository $tagRepository, LoggerInterface $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 /**
@@ -81,6 +84,11 @@ class ContentProxy
81 $entry->setPreviewPicture($content['open_graph']['og_image']); 84 $entry->setPreviewPicture($content['open_graph']['og_image']);
82 } 85 }
83 86
87 // if content is an image define as a preview too
88 if (in_array($this->mimeGuesser->guess($content['content_type']), ['jpeg', 'jpg', 'gif', 'png'], true)) {
89 $entry->setPreviewPicture($content['url']);
90 }
91
84 try { 92 try {
85 $this->tagger->tag($entry); 93 $this->tagger->tag($entry);
86 } catch (\Exception $e) { 94 } catch (\Exception $e) {