diff options
author | Jeremy Benoist <jeremy.benoist@gmail.com> | 2016-10-30 19:50:00 +0100 |
---|---|---|
committer | Jeremy Benoist <jeremy.benoist@gmail.com> | 2016-10-30 19:50:00 +0100 |
commit | 41ada277f066ea57947bce05bcda63962b7fea55 (patch) | |
tree | 2c81f8bc70cc2e0a625924ccdb5d9bc649d8292d /src/Wallabag | |
parent | 48656e0eaac006a80f21e9aec8900747fe76283a (diff) | |
download | wallabag-41ada277f066ea57947bce05bcda63962b7fea55.tar.gz wallabag-41ada277f066ea57947bce05bcda63962b7fea55.tar.zst wallabag-41ada277f066ea57947bce05bcda63962b7fea55.zip |
Add instance url to the downloaded images
Diffstat (limited to 'src/Wallabag')
-rw-r--r-- | src/Wallabag/CoreBundle/Event/Subscriber/DownloadImagesSubscriber.php | 4 | ||||
-rw-r--r-- | src/Wallabag/CoreBundle/Helper/DownloadImages.php | 14 |
2 files changed, 17 insertions, 1 deletions
diff --git a/src/Wallabag/CoreBundle/Event/Subscriber/DownloadImagesSubscriber.php b/src/Wallabag/CoreBundle/Event/Subscriber/DownloadImagesSubscriber.php index 09f8e911..0792653e 100644 --- a/src/Wallabag/CoreBundle/Event/Subscriber/DownloadImagesSubscriber.php +++ b/src/Wallabag/CoreBundle/Event/Subscriber/DownloadImagesSubscriber.php | |||
@@ -110,6 +110,8 @@ class DownloadImagesSubscriber implements EventSubscriber | |||
110 | */ | 110 | */ |
111 | public function downloadImages(Config $config, Entry $entry) | 111 | public function downloadImages(Config $config, Entry $entry) |
112 | { | 112 | { |
113 | $this->downloadImages->setWallabagUrl($config->get('wallabag_url')); | ||
114 | |||
113 | // if ($config->get('download_images_with_rabbitmq')) { | 115 | // if ($config->get('download_images_with_rabbitmq')) { |
114 | 116 | ||
115 | // } else if ($config->get('download_images_with_redis')) { | 117 | // } else if ($config->get('download_images_with_redis')) { |
@@ -132,6 +134,8 @@ class DownloadImagesSubscriber implements EventSubscriber | |||
132 | */ | 134 | */ |
133 | public function downloadPreviewImage(Config $config, Entry $entry) | 135 | public function downloadPreviewImage(Config $config, Entry $entry) |
134 | { | 136 | { |
137 | $this->downloadImages->setWallabagUrl($config->get('wallabag_url')); | ||
138 | |||
135 | // if ($config->get('download_images_with_rabbitmq')) { | 139 | // if ($config->get('download_images_with_rabbitmq')) { |
136 | 140 | ||
137 | // } else if ($config->get('download_images_with_redis')) { | 141 | // } else if ($config->get('download_images_with_redis')) { |
diff --git a/src/Wallabag/CoreBundle/Helper/DownloadImages.php b/src/Wallabag/CoreBundle/Helper/DownloadImages.php index 004bb277..e7982c56 100644 --- a/src/Wallabag/CoreBundle/Helper/DownloadImages.php +++ b/src/Wallabag/CoreBundle/Helper/DownloadImages.php | |||
@@ -15,6 +15,7 @@ class DownloadImages | |||
15 | private $baseFolder; | 15 | private $baseFolder; |
16 | private $logger; | 16 | private $logger; |
17 | private $mimeGuesser; | 17 | private $mimeGuesser; |
18 | private $wallabagUrl; | ||
18 | 19 | ||
19 | public function __construct(Client $client, $baseFolder, LoggerInterface $logger) | 20 | public function __construct(Client $client, $baseFolder, LoggerInterface $logger) |
20 | { | 21 | { |
@@ -27,6 +28,17 @@ class DownloadImages | |||
27 | } | 28 | } |
28 | 29 | ||
29 | /** | 30 | /** |
31 | * Since we can't inject CraueConfig service because it'll generate a circular reference when injected in the subscriber | ||
32 | * we use a different way to inject the current wallabag url. | ||
33 | * | ||
34 | * @param string $url Usually from `$config->get('wallabag_url')` | ||
35 | */ | ||
36 | public function setWallabagUrl($url) | ||
37 | { | ||
38 | $this->wallabagUrl = rtrim($url, '/'); | ||
39 | } | ||
40 | |||
41 | /** | ||
30 | * Setup base folder where all images are going to be saved. | 42 | * Setup base folder where all images are going to be saved. |
31 | */ | 43 | */ |
32 | private function setFolder() | 44 | private function setFolder() |
@@ -143,7 +155,7 @@ class DownloadImages | |||
143 | 155 | ||
144 | imagedestroy($im); | 156 | imagedestroy($im); |
145 | 157 | ||
146 | return '/assets/images/'.$relativePath.'/'.$hashImage.'.'.$ext; | 158 | return $this->wallabagUrl.'/assets/images/'.$relativePath.'/'.$hashImage.'.'.$ext; |
147 | } | 159 | } |
148 | 160 | ||
149 | /** | 161 | /** |