mirror of
https://github.com/ToxicCrack/PrintABrick.git
synced 2025-05-16 20:30:09 -07:00
Revert Image loader changes
This commit is contained in:
parent
1c12e34bb2
commit
8f4c7f09da
@ -7,7 +7,7 @@
|
|||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
<img src="{{ placeholder }}"
|
<img src="{{ placeholder }}"
|
||||||
data-src="{{ asset(color~'/'~number) | imagine_filter(filter) }}"
|
data-src="{{ asset(color~'/'~number~'.png') | imagine_filter(filter) }}"
|
||||||
alt="{{ 'part.image.alt'|trans({'%number%':number}) }}">
|
alt="{{ 'part.image.alt'|trans({'%number%':number}) }}">
|
||||||
</div>
|
</div>
|
||||||
{% endmacro %}
|
{% endmacro %}
|
||||||
@ -21,7 +21,7 @@
|
|||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
<img src="{{ placeholder }}"
|
<img src="{{ placeholder }}"
|
||||||
data-src="{{ number|imagine_filter(filter) }}"
|
data-src="{{ asset(number~'.jpg')|imagine_filter(filter) }}"
|
||||||
alt="{{ 'set.image.alt'|trans({'%number%':number}) }}">
|
alt="{{ 'set.image.alt'|trans({'%number%':number}) }}">
|
||||||
</div>
|
</div>
|
||||||
{% endmacro %}
|
{% endmacro %}
|
||||||
|
@ -11,7 +11,7 @@
|
|||||||
model.id~' '~model.name,
|
model.id~' '~model.name,
|
||||||
app.request.uri,
|
app.request.uri,
|
||||||
'meta.description' | trans | striptags('sup'),
|
'meta.description' | trans | striptags('sup'),
|
||||||
asset('-1/'~model.id) | imagine_filter('part_large')
|
asset('-1/'~model.id~'.png') | imagine_filter('part_large')
|
||||||
)}}
|
)}}
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
|
@ -11,7 +11,7 @@
|
|||||||
set.id~' '~set.name ,
|
set.id~' '~set.name ,
|
||||||
app.request.uri,
|
app.request.uri,
|
||||||
'meta.description' | trans | striptags('sup'),
|
'meta.description' | trans | striptags('sup'),
|
||||||
asset(set.id)|imagine_filter('set_large')
|
asset(set.id~'.jpg')|imagine_filter('set_large')
|
||||||
)}}
|
)}}
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
|
@ -54,7 +54,7 @@ class SearchController extends Controller
|
|||||||
'id' => $id,
|
'id' => $id,
|
||||||
'name' => $name,
|
'name' => $name,
|
||||||
'url' => $this->generateUrl('model_detail', ['id' => $model->getTransformed()->getId()]),
|
'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,
|
'id' => $id,
|
||||||
'name' => $name,
|
'name' => $name,
|
||||||
'url' => $this->generateUrl('set_detail', ['id' => $set->getTransformed()->getId()]),
|
'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'),
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -31,25 +31,21 @@ class PartImageLoader extends BaseImageLoader
|
|||||||
|
|
||||||
public function find($path)
|
public function find($path)
|
||||||
{
|
{
|
||||||
$localPath = '/images/'.$path.'.png';
|
|
||||||
|
|
||||||
// try to load image from local mediaFilesystem
|
// try to load image from local mediaFilesystem
|
||||||
if ($this->mediaFilesystem->has($localPath)) {
|
if ($this->mediaFilesystem->has('/images/'.$path)) {
|
||||||
return $this->mediaFilesystem->read($localPath);
|
return $this->mediaFilesystem->read('/images/'.$path);
|
||||||
}
|
}
|
||||||
|
|
||||||
$rebrickablePath = $this->rebrickableContext.strtolower($path).'.png';
|
|
||||||
|
|
||||||
// try to load image from rebrickable website
|
// 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']]);
|
$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
|
// Load part entity form rebrickable api and get image path from response
|
||||||
try {
|
try {
|
||||||
if (preg_match('/^(.*)\/(.*)$/', $path, $match)) {
|
if (preg_match('/^(.*)\/(.*).png$/', $path, $match)) {
|
||||||
$part = $this->rebrickableManager->getPart($match[2]);
|
$part = $this->rebrickableManager->getPart($match[2]);
|
||||||
|
|
||||||
if ($part && $part->getImgUrl()) {
|
if ($part && $part->getImgUrl()) {
|
||||||
|
@ -29,28 +29,28 @@ class SetImageLoader extends BaseImageLoader
|
|||||||
$this->mediaFilesystem = $mediaFilesystem;
|
$this->mediaFilesystem = $mediaFilesystem;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function find($setNumber)
|
public function find($path)
|
||||||
{
|
{
|
||||||
$rebrickablePath = $this->rebrickableContext.strtolower($setNumber).'.jpg';
|
|
||||||
|
|
||||||
// try to load image from rebrickable website
|
// 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']]);
|
$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
|
// Load part entity form brickset api and get image path from response
|
||||||
try {
|
try {
|
||||||
$set = $this->bricksetManager->getSetByNumber($setNumber);
|
if (preg_match('/^(.*)(.png|.jpg)$/', $path, $match)) {
|
||||||
|
$set = $this->bricksetManager->getSetByNumber($match[1]);
|
||||||
|
|
||||||
if ($set && $set->getImage()) {
|
if ($set && $set->getImage()) {
|
||||||
return file_get_contents($set->getImageURL());
|
return file_get_contents($set->getImageURL());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} catch (\Exception $e) {
|
} 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));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user