diff --git a/app/Resources/views/macros/blocks.html.twig b/app/Resources/views/macros/blocks.html.twig
index 7f93a3d..8e448ab 100644
--- a/app/Resources/views/macros/blocks.html.twig
+++ b/app/Resources/views/macros/blocks.html.twig
@@ -7,7 +7,7 @@
{% endif %}
{% endmacro %}
@@ -21,7 +21,7 @@
{% endif %}
{% endmacro %}
diff --git a/app/Resources/views/model/detail.html.twig b/app/Resources/views/model/detail.html.twig
index 5458fe5..aeeda30 100644
--- a/app/Resources/views/model/detail.html.twig
+++ b/app/Resources/views/model/detail.html.twig
@@ -11,7 +11,7 @@
model.id~' '~model.name,
app.request.uri,
'meta.description' | trans | striptags('sup'),
- asset('-1/'~model.id) | imagine_filter('part_large')
+ asset('-1/'~model.id~'.png') | imagine_filter('part_large')
)}}
{% endblock %}
diff --git a/app/Resources/views/set/detail.html.twig b/app/Resources/views/set/detail.html.twig
index 07daed0..fea310a 100644
--- a/app/Resources/views/set/detail.html.twig
+++ b/app/Resources/views/set/detail.html.twig
@@ -11,7 +11,7 @@
set.id~' '~set.name ,
app.request.uri,
'meta.description' | trans | striptags('sup'),
- asset(set.id)|imagine_filter('set_large')
+ asset(set.id~'.jpg')|imagine_filter('set_large')
)}}
{% endblock %}
diff --git a/src/FrontBundle/Controller/SearchController.php b/src/FrontBundle/Controller/SearchController.php
index 6b69815..659ce77 100644
--- a/src/FrontBundle/Controller/SearchController.php
+++ b/src/FrontBundle/Controller/SearchController.php
@@ -54,7 +54,7 @@ class SearchController extends Controller
'id' => $id,
'name' => $name,
'url' => $this->generateUrl('model_detail', ['id' => $model->getTransformed()->getId()]),
- 'img' => $liip->getBrowserPath('-1/'.$model->getTransformed()->getId(), 'part_min'),
+ 'img' => $liip->getBrowserPath('-1/'.$model->getTransformed()->getId().'.png', 'part_min'),
];
}
@@ -68,7 +68,7 @@ class SearchController extends Controller
'id' => $id,
'name' => $name,
'url' => $this->generateUrl('set_detail', ['id' => $set->getTransformed()->getId()]),
- 'img' => $liip->getBrowserPath($set->getTransformed()->getId(), 'set_min'),
+ 'img' => $liip->getBrowserPath($set->getTransformed()->getId().'.jpg', 'set_min'),
];
}
diff --git a/src/FrontBundle/Imagine/PartImageLoader.php b/src/FrontBundle/Imagine/PartImageLoader.php
index ab78e0c..4254456 100644
--- a/src/FrontBundle/Imagine/PartImageLoader.php
+++ b/src/FrontBundle/Imagine/PartImageLoader.php
@@ -31,25 +31,21 @@ class PartImageLoader extends BaseImageLoader
public function find($path)
{
- $localPath = '/images/'.$path.'.png';
-
// try to load image from local mediaFilesystem
- if ($this->mediaFilesystem->has($localPath)) {
- return $this->mediaFilesystem->read($localPath);
+ if ($this->mediaFilesystem->has('/images/'.$path)) {
+ return $this->mediaFilesystem->read('/images/'.$path);
}
- $rebrickablePath = $this->rebrickableContext.strtolower($path).'.png';
-
// try to load image from rebrickable website
- if ($this->remoteFileExists($rebrickablePath)) {
+ if ($this->remoteFileExists($this->rebrickableContext.$path)) {
$context = stream_context_create(['http' => ['header' => 'Connection: close\r\n']]);
- return file_get_contents($rebrickablePath, false, $context);
+ return file_get_contents($this->rebrickableContext.strtolower($path), false, $context);
}
// Load part entity form rebrickable api and get image path from response
try {
- if (preg_match('/^(.*)\/(.*)$/', $path, $match)) {
+ if (preg_match('/^(.*)\/(.*).png$/', $path, $match)) {
$part = $this->rebrickableManager->getPart($match[2]);
if ($part && $part->getImgUrl()) {
diff --git a/src/FrontBundle/Imagine/SetImageLoader.php b/src/FrontBundle/Imagine/SetImageLoader.php
index 606ade4..7766a55 100644
--- a/src/FrontBundle/Imagine/SetImageLoader.php
+++ b/src/FrontBundle/Imagine/SetImageLoader.php
@@ -29,28 +29,28 @@ class SetImageLoader extends BaseImageLoader
$this->mediaFilesystem = $mediaFilesystem;
}
- public function find($setNumber)
+ public function find($path)
{
- $rebrickablePath = $this->rebrickableContext.strtolower($setNumber).'.jpg';
-
// try to load image from rebrickable website
- if ($this->remoteFileExists($rebrickablePath)) {
+ if ($this->remoteFileExists($this->rebrickableContext.strtolower($path))) {
$context = stream_context_create(['http' => ['header' => 'Connection: close\r\n']]);
- return file_get_contents($rebrickablePath, false, $context);
+ return file_get_contents($this->rebrickableContext.strtolower($path), false, $context);
}
// Load part entity form brickset api and get image path from response
try {
- $set = $this->bricksetManager->getSetByNumber($setNumber);
+ if (preg_match('/^(.*)(.png|.jpg)$/', $path, $match)) {
+ $set = $this->bricksetManager->getSetByNumber($match[1]);
- if ($set && $set->getImage()) {
- return file_get_contents($set->getImageURL());
+ if ($set && $set->getImage()) {
+ return file_get_contents($set->getImageURL());
+ }
}
} catch (\Exception $e) {
- throw new NotLoadableException(sprintf('Image %s could not be loaded.', $setNumber), $e->getCode(), $e);
+ throw new NotLoadableException(sprintf('Source image %s could not be loaded.', $path), $e->getCode(), $e);
}
- throw new NotLoadableException(sprintf('Image %s not found.', $setNumber));
+ throw new NotLoadableException(sprintf('Source image %s not found.', $path));
}
}