mirror of
https://github.com/Part-DB/Part-DB-server.git
synced 2025-07-12 19:34:31 +02:00
Use preview image and other additional images provided by the info provider
This commit is contained in:
parent
701212239d
commit
db97114fb4
2 changed files with 38 additions and 3 deletions
|
@ -162,6 +162,30 @@ final class DTOtoEntityConverter
|
|||
$entity->addParameter($this->convertParameter($parameter));
|
||||
}
|
||||
|
||||
//Add preview image
|
||||
$image_type = $this->getImageType();
|
||||
|
||||
if ($dto->preview_image_url) {
|
||||
$preview_image = new PartAttachment();
|
||||
$preview_image->setURL($dto->preview_image_url);
|
||||
$preview_image->setName('Main image');
|
||||
$preview_image->setAttachmentType($image_type);
|
||||
|
||||
$entity->addAttachment($preview_image);
|
||||
$entity->setMasterPictureAttachment($preview_image);
|
||||
}
|
||||
|
||||
//Add other images
|
||||
foreach ($dto->images ?? [] as $image) {
|
||||
//Ensure that the image is not the same as the preview image
|
||||
if ($image->url === $dto->preview_image_url) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$entity->addAttachment($this->convertFile($image, $image_type));
|
||||
}
|
||||
|
||||
|
||||
//Add datasheets
|
||||
$datasheet_type = $this->getDatasheetType();
|
||||
foreach ($dto->datasheets ?? [] as $datasheet) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue