1
0
mirror of https://github.com/ToxicCrack/PrintABrick.git synced 2025-05-19 21:50:08 -07:00

Fix Image loaders

This commit is contained in:
David Hübner 2017-05-17 20:22:44 +02:00
parent 5c2421d5fb
commit e13c6d4324
3 changed files with 9 additions and 8 deletions

View File

@ -2,7 +2,6 @@
namespace AppBundle\Imagine;
use Liip\ImagineBundle\Binary\Loader\LoaderInterface;
abstract class BaseImageLoader implements LoaderInterface
@ -24,4 +23,4 @@ abstract class BaseImageLoader implements LoaderInterface
return $status === 200 ? true : false;
}
}
}

View File

@ -57,6 +57,7 @@ class PartImageLoader extends BaseImageLoader
throw new NotLoadableException(sprintf('Source image %s could not be loaded.', $path), $e->getCode(), $e);
}
return $this->mediaFilesystem->read('noimage.png');
throw new NotLoadableException(sprintf('Source image %s not found.', $path));
// return $this->mediaFilesystem->read('noimage.png');
}
}

View File

@ -31,16 +31,16 @@ class SetImageLoader extends BaseImageLoader
{
// try to load image from rebrickable website
try {
if ($this->remoteFileExists($this->rebrickableContext.$path)) {
return file_get_contents($this->rebrickableContext.$path);
if ($this->remoteFileExists($this->rebrickableContext.strtolower($path))) {
return file_get_contents($this->rebrickableContext.strtolower($path));
}
} catch (\Exception $e) {
throw new NotLoadableException(sprintf('Source image %s could not be loaded.', $path), $e->getCode(), $e);
}
// Load part entity form rebrickable api and get image path from response
// Load part entity form brickset api and get image path from response
try {
if (preg_match('/^(.*)[.png|.jpg]$/', $path, $match)) {
if (preg_match('/^(.*)(.png|.jpg)$/', $path, $match)) {
$set = $this->bricksetManager->getSetByNumber($match[1]);
if ($set && $set->getImage()) {
@ -51,6 +51,7 @@ class SetImageLoader extends BaseImageLoader
throw new NotLoadableException(sprintf('Source image %s could not be loaded.', $path), $e->getCode(), $e);
}
return $this->mediaFilesystem->read('noimage.png');
throw new NotLoadableException(sprintf('Source image %s not found.', $path));
// return $this->mediaFilesystem->read('noimage.png');
}
}